From 635f0ed47ffe11e93d96e4d24e4411eedfa1ddc9 Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Fri, 8 Feb 2019 15:02:11 -0800 Subject: [PATCH] tidyup retired modules and add aspectjtools submodule --- README.md | 24 + README.txt | 2 - aspectj-attic/.classpath | 13 - aspectj-attic/.project | 19 - aspectj-attic/ajdoc-src/devnotes.txt | 98 -- .../org/aspectj/ajdoc/AdviceDoc.java | 87 -- .../org/aspectj/ajdoc/AspectDoc.java | 83 -- .../ajdoc-src/org/aspectj/ajdoc/ClassDoc.java | 58 - .../org/aspectj/ajdoc/ConstructorDoc.java | 31 - .../ajdoc-src/org/aspectj/ajdoc/Doc.java | 45 - .../aspectj/ajdoc/ExecutableMemberDoc.java | 41 - .../ajdoc-src/org/aspectj/ajdoc/FieldDoc.java | 30 - .../org/aspectj/ajdoc/IntroducedDoc.java | 37 - .../org/aspectj/ajdoc/IntroducedSuperDoc.java | 50 - .../org/aspectj/ajdoc/IntroductionDoc.java | 38 - .../org/aspectj/ajdoc/MemberDoc.java | 43 - .../org/aspectj/ajdoc/MethodDoc.java | 32 - .../org/aspectj/ajdoc/OfClauseDoc.java | 79 -- .../org/aspectj/ajdoc/OfEachObjectDoc.java | 42 - .../org/aspectj/ajdoc/PackageDoc.java | 40 - .../ajdoc-src/org/aspectj/ajdoc/ParamTag.java | 24 - .../org/aspectj/ajdoc/Parameter.java | 24 - .../org/aspectj/ajdoc/PointcutDoc.java | 61 - .../org/aspectj/ajdoc/ProgramElementDoc.java | 31 - .../ajdoc-src/org/aspectj/ajdoc/RootDoc.java | 31 - .../ajdoc-src/org/aspectj/ajdoc/SeeTag.java | 24 - .../org/aspectj/ajdoc/SerialFieldTag.java | 24 - .../ajdoc-src/org/aspectj/ajdoc/Tag.java | 24 - .../org/aspectj/ajdoc/ThrowsTag.java | 24 - .../ajdoc-src/org/aspectj/ajdoc/Type.java | 31 - .../org/aspectj/tools/ajdoc/Access.java | 197 --- .../aspectj/tools/ajdoc/AccessChecker.java | 178 --- .../aspectj/tools/ajdoc/AdviceDocImpl.java | 199 --- .../org/aspectj/tools/ajdoc/Ajdoc.java | 384 ------ .../aspectj/tools/ajdoc/AjdocCompiler.java | 605 --------- .../aspectj/tools/ajdoc/AspectDocImpl.java | 300 ----- .../ajdoc/CannotMakeRootDocException.java | 72 - .../org/aspectj/tools/ajdoc/ClassDocImpl.java | 1107 ---------------- .../org/aspectj/tools/ajdoc/CodeDocImpl.java | 82 -- .../org/aspectj/tools/ajdoc/Comment.java | 336 ----- .../tools/ajdoc/ConstructorDocImpl.java | 64 - .../org/aspectj/tools/ajdoc/DocImpl.java | 280 ---- .../org/aspectj/tools/ajdoc/DocletProxy.java | 145 -- .../org/aspectj/tools/ajdoc/ErrPrinter.java | 627 --------- .../tools/ajdoc/ExecutableMemberDocImpl.java | 307 ----- .../org/aspectj/tools/ajdoc/FieldDocImpl.java | 140 -- .../aspectj/tools/ajdoc/FilteredDecList.java | 219 --- .../tools/ajdoc/IntroducedDocImpl.java | 169 --- .../tools/ajdoc/IntroducedSuperDocImpl.java | 103 -- .../tools/ajdoc/IntroductionDocImpl.java | 86 -- .../org/aspectj/tools/ajdoc/Main.java | 112 -- .../aspectj/tools/ajdoc/MemberDocImpl.java | 82 -- .../aspectj/tools/ajdoc/MethodDocImpl.java | 125 -- .../aspectj/tools/ajdoc/OfClauseDocImpl.java | 95 -- .../aspectj/tools/ajdoc/PackageDocImpl.java | 336 ----- .../org/aspectj/tools/ajdoc/ParamTagImpl.java | 86 -- .../aspectj/tools/ajdoc/ParameterImpl.java | 70 - .../aspectj/tools/ajdoc/PointcutDocImpl.java | 143 -- .../tools/ajdoc/ProgramElementDocImpl.java | 203 --- .../org/aspectj/tools/ajdoc/Quietable.java | 42 - .../org/aspectj/tools/ajdoc/RootDocImpl.java | 404 ------ .../org/aspectj/tools/ajdoc/RootDocMaker.java | 72 - .../org/aspectj/tools/ajdoc/SeeTagImpl.java | 874 ------------ .../tools/ajdoc/SerialFieldTagImpl.java | 173 --- .../org/aspectj/tools/ajdoc/TagImpl.java | 181 --- .../aspectj/tools/ajdoc/ThrowsTagImpl.java | 104 -- .../org/aspectj/tools/ajdoc/TypeImpl.java | 165 --- .../org/aspectj/tools/ajdoc/Util.java | 933 ------------- .../tools/ajdoc/resources/ajdoc.properties | 77 -- .../tools/ajdoc/rootmakers/Javadoc.java | 151 --- .../tools/ajdoc/rootmakers/Javadoc13.java | 77 -- .../tools/ajdoc/rootmakers/Javadoc14.java | 273 ---- .../doclets/standard/AbstractIndexWriter.java | 85 -- .../doclets/standard/AbstractStandard.java | 477 ------- .../doclets/standard/AbstractSubWriter.java | 393 ------ .../doclets/standard/AbstractSubWriterAJ.java | 33 - .../doclets/standard/AbstractTreeWriter.java | 104 -- .../doclets/standard/AdviceSubWriter.java | 273 ---- .../doclets/standard/ClassSubWriter.java | 109 -- .../doclets/standard/ClassUseMapper.java | 294 ---- .../doclets/standard/ClassUseWriter.java | 272 ---- .../tools/doclets/standard/ClassWriter.java | 554 -------- .../standard/ConfigurationStandard.java | 120 -- .../ConstructorIntroductionSubWriter.java | 126 -- .../standard/ConstructorSubWriter.java | 85 -- .../standard/DeprecatedAPIListBuilder.java | 120 -- .../standard/DeprecatedListWriter.java | 94 -- .../standard/ExecutableMemberSubWriter.java | 139 -- .../standard/FieldIntroductionSubWriter.java | 131 -- .../doclets/standard/FieldSubWriter.java | 116 -- .../standard/MethodIntroductionSubWriter.java | 136 -- .../doclets/standard/MethodSubWriter.java | 112 -- .../doclets/standard/PackageFrameWriter.java | 75 -- .../doclets/standard/PackageTreeWriter.java | 97 -- .../tools/doclets/standard/PackageWriter.java | 79 -- .../doclets/standard/PointcutSubWriter.java | 227 ---- .../doclets/standard/SingleIndexWriter.java | 87 -- .../doclets/standard/SplitIndexWriter.java | 99 -- .../tools/doclets/standard/Standard.java | 251 ---- .../tools/doclets/standard/Statics.java | 253 ---- .../standard/SubWriterHolderWriter.java | 66 - .../standard/SuperIntroductionSubWriter.java | 181 --- .../tools/doclets/standard/TreeWriter.java | 86 -- .../standard/resources/standard.properties | 344 ----- .../ajdoc-testsrc/AjdocModuleTests.java | 39 - .../org/aspectj/tools/ajdoc/AjdocTests.java | 41 - .../org/aspectj/tools/ajdoc/JUnitDriver.java | 117 -- .../aspectj/tools/ajdoc/SeeTagImplTest.java | 493 ------- .../aspectj/tools/ajdoc/genSeeTestCases.sh | 35 - .../readme-aspectj-attic-module.html | 28 - aspectj-attic/testing-src/AjcTaskTester.java | 219 --- aspectj-attic/testing-src/AjcTaskTester2.java | 202 --- .../testing-src/AjdocTaskTester.java | 366 ----- aspectj-attic/testing-src/AntTaskTester.java | 409 ------ .../aspectj/testing/compare/CompareFiles.java | 571 -------- .../aspectj/testing/compare/CompareUtil.java | 143 -- .../testing/compare/GenericTreeNode.java | 427 ------ .../GenericTreeNodeListOrdererFactoryI.java | 30 - .../compare/GenericTreeNodeListOrdererI.java | 44 - .../compare/GenericTreeNodesVisitorI.java | 31 - .../org/aspectj/testing/compare/Regexp.java | 40 - .../testing/compare/RegexpFactory.java | 64 - .../aspectj/testing/compare/RegexpFilter.java | 622 --------- .../testing/compare/RegexpFilterReader.java | 291 ---- .../aspectj/testing/compare/TreeCompare.java | 217 --- .../adapters/GenericTreeNodeFactoryI.java | 33 - .../JTreeNodeGenericTreeNodeFactory.java | 102 -- .../testing/compare/adapters/Structure.java | 438 ------ .../StructureGenericTreeNodeFactory.java | 308 ----- .../compare/adapters/SubTypeComparator.java | 224 ---- .../testing/compare/adapters/package.html | 50 - .../org/aspectj/testing/compare/package.html | 128 -- .../testing/taskdefs/CompareFiles.java | 103 -- aspectj5rt/.classpath | 36 - aspectj5rt/.cvsignore | 2 - aspectj5rt/.project | 17 - .../.settings/org.eclipse.jdt.core.prefs | 62 - aspectj5rt/aspectj5rt.mf.txt | 15 - aspectj5rt/build.xml | 6 - .../lang/annotation/ajcDeclareAnnotation.java | 25 - .../lang/annotation/ajcDeclareEoW.java | 31 - .../lang/annotation/ajcDeclareParents.java | 31 - .../lang/annotation/ajcDeclarePrecedence.java | 32 - .../lang/annotation/ajcDeclareSoft.java | 30 - .../internal/lang/annotation/ajcITD.java | 31 - .../lang/annotation/ajcPrivileged.java | 27 - .../internal/lang/reflect/AdviceImpl.java | 187 --- .../internal/lang/reflect/AjTypeImpl.java | 1179 ----------------- .../lang/reflect/DeclareAnnotationImpl.java | 115 -- .../reflect/DeclareErrorOrWarningImpl.java | 71 - .../lang/reflect/DeclareParentsImpl.java | 98 -- .../lang/reflect/DeclarePrecedenceImpl.java | 62 - .../lang/reflect/DeclareSoftImpl.java | 76 -- .../InterTypeConstructorDeclarationImpl.java | 100 -- .../reflect/InterTypeDeclarationImpl.java | 68 - .../InterTypeFieldDeclarationImpl.java | 90 -- .../InterTypeMethodDeclarationImpl.java | 148 --- .../internal/lang/reflect/PerClauseImpl.java | 39 - .../reflect/PointcutBasedPerClauseImpl.java | 49 - .../lang/reflect/PointcutExpressionImpl.java | 32 - .../internal/lang/reflect/PointcutImpl.java | 100 -- .../lang/reflect/SignaturePatternImpl.java | 37 - .../internal/lang/reflect/StringToType.java | 83 -- .../TypePatternBasedPerClauseImpl.java | 43 - .../lang/reflect/TypePatternImpl.java | 37 - .../java5-src/org/aspectj/lang/Aspects.java | 190 --- .../aspectj/lang/annotation/AdviceName.java | 31 - .../org/aspectj/lang/annotation/After.java | 41 - .../lang/annotation/AfterReturning.java | 52 - .../lang/annotation/AfterThrowing.java | 52 - .../org/aspectj/lang/annotation/Around.java | 42 - .../org/aspectj/lang/annotation/Aspect.java | 34 - .../org/aspectj/lang/annotation/Before.java | 42 - .../lang/annotation/DeclareAnnotation.java | 31 - .../aspectj/lang/annotation/DeclareError.java | 33 - .../aspectj/lang/annotation/DeclareMixin.java | 42 - .../lang/annotation/DeclareParents.java | 41 - .../lang/annotation/DeclarePrecedence.java | 33 - .../lang/annotation/DeclareWarning.java | 33 - .../org/aspectj/lang/annotation/Pointcut.java | 42 - .../lang/annotation/RequiredTypes.java | 30 - .../lang/annotation/SuppressAjWarnings.java | 31 - .../control/CodeGenerationHint.java | 34 - .../org/aspectj/lang/reflect/Advice.java | 59 - .../org/aspectj/lang/reflect/AdviceKind.java | 23 - .../org/aspectj/lang/reflect/AjType.java | 380 ------ .../aspectj/lang/reflect/AjTypeSystem.java | 55 - .../lang/reflect/DeclareAnnotation.java | 56 - .../lang/reflect/DeclareErrorOrWarning.java | 40 - .../aspectj/lang/reflect/DeclareParents.java | 47 - .../lang/reflect/DeclarePrecedence.java | 32 - .../org/aspectj/lang/reflect/DeclareSoft.java | 34 - .../InterTypeConstructorDeclaration.java | 36 - .../lang/reflect/InterTypeDeclaration.java | 33 - .../reflect/InterTypeFieldDeclaration.java | 36 - .../reflect/InterTypeMethodDeclaration.java | 57 - .../lang/reflect/NoSuchAdviceException.java | 34 - .../lang/reflect/NoSuchPointcutException.java | 34 - .../org/aspectj/lang/reflect/PerClause.java | 23 - .../aspectj/lang/reflect/PerClauseKind.java | 25 - .../org/aspectj/lang/reflect/Pointcut.java | 52 - .../lang/reflect/PointcutBasedPerClause.java | 25 - .../lang/reflect/PointcutExpression.java | 24 - .../lang/reflect/SignaturePattern.java | 23 - .../org/aspectj/lang/reflect/TypePattern.java | 22 - .../reflect/TypePatternBasedPerClause.java | 26 - .../Aspectj5rt15ModuleTests.java | 34 - .../internal/lang/reflect/AjTypeTests.java | 327 ----- .../lang/reflect/AjTypeTestsWithAspects.java | 449 ------- .../internal/lang/reflect/InterTypeTests.java | 88 -- .../lang/internal/lang/PlaceHolder.java | 18 - .../runtime/Aspectj5rtModuleTests.java | 33 - aspectjtools/aspectjtools-assembly.xml | 136 ++ .../aspectjtools-sources-assembly.xml | 85 ++ aspectjtools/pom.xml | 166 +++ docs/.project | 17 - loadtime5/.classpath | 15 - loadtime5/.cvsignore | 1 - loadtime5/.project | 17 - .../.settings/org.eclipse.jdt.core.prefs | 11 - loadtime5/build.xml | 6 - .../org/aspectj/weaver/loadtime/Agent.java | 67 - .../ClassPreProcessorAgentAdapter.java | 53 - .../java5-testsrc/Loadtime515ModuleTests.java | 29 - .../weaver/loadtime/LoadtimeTests.java | 26 - loadtime5/loadtime5.mf.txt | 12 - .../loadtime/Loadtime5ModuleTests.java | 37 - weaver5/.classpath | 17 - weaver5/.cvsignore | 6 - weaver5/.project | 17 - weaver5/.settings/org.eclipse.jdt.core.prefs | 61 - weaver5/.settings/org.eclipse.jdt.ui.prefs | 3 - weaver5/build.xml | 6 - .../aspectj/weaver/reflect/ArgNameFinder.java | 26 - .../DeferredResolvedPointcutDefinition.java | 35 - .../InternalUseOnlyPointcutParser.java | 43 - .../reflect/Java15AnnotationFinder.java | 386 ------ ...15GenericSignatureInformationProvider.java | 103 -- ...5ReflectionBasedReferenceTypeDelegate.java | 389 ------ .../JavaLangTypeToResolvedTypeConverter.java | 134 -- .../org/aspectj/weaver/tools/Jdk14Trace.java | 127 -- .../weaver/tools/Jdk14TraceFactory.java | 20 - weaver5/java5-testsrc/$Proxy1.java | 28 - weaver5/java5-testsrc/CounterAspect.java | 52 - weaver5/java5-testsrc/GenericService.java | 17 - weaver5/java5-testsrc/MA.java | 15 - weaver5/java5-testsrc/MB.java | 15 - weaver5/java5-testsrc/MC.java | 15 - weaver5/java5-testsrc/MD.java | 15 - weaver5/java5-testsrc/MessageService.java | 13 - ...nWorldAdvancedPointcutExpressionTests.java | 30 - .../org/aspectj/weaver/AllTracing5Tests.java | 27 - .../org/aspectj/weaver/AllWeaver5Tests.java | 40 - .../aspectj/weaver/BcweaverModuleTests15.java | 41 - .../weaver/BoundedReferenceTypeTestCase.java | 106 -- .../weaver/CommonReferenceTypeTests.java | 91 -- .../aspectj/weaver/Jdk14TraceFactoryTest.java | 30 - .../org/aspectj/weaver/Jdk14TraceTest.java | 34 - .../JoinPointSignatureIteratorTests.java | 107 -- .../org/aspectj/weaver/MemberTestCase15.java | 155 --- .../aspectj/weaver/ReferenceTypeTestCase.java | 854 ------------ ...5ReflectionBasedReferenceTypeDelegate.java | 154 --- .../TypeVariableReferenceTypeTestCase.java | 81 -- .../aspectj/weaver/TypeVariableTestCase.java | 110 -- .../BcelGenericSignatureToTypeXTestCase.java | 68 - .../bcel/BcelWorldReferenceTypeTest.java | 23 - .../WildTypePatternResolutionTestCase.java | 422 ------ ...lectionBasedReferenceTypeDelegateTest.java | 316 ----- .../ReflectionWorldReferenceTypeTest.java | 27 - .../weaver/reflect/ReflectionWorldTest.java | 290 ---- .../tools/Java15PointcutExpressionTest.java | 746 ----------- weaver5/java5-testsrc/test/A.java | 27 - weaver5/java5-testsrc/test/A1.java | 20 - .../java5-testsrc/test/A1AnnotatedType.java | 17 - weaver5/java5-testsrc/test/A2.java | 20 - .../java5-testsrc/test/A2AnnotatedType.java | 17 - weaver5/java5-testsrc/test/A3.java | 19 - weaver5/java5-testsrc/test/AnnoValues.java | 20 - weaver5/java5-testsrc/test/Color.java | 14 - weaver5/testdata/logging.properties | 60 - .../aspectj/weaver/Weaver5ModuleTests.java | 37 - 281 files changed, 411 insertions(+), 34732 deletions(-) create mode 100644 README.md delete mode 100644 README.txt delete mode 100644 aspectj-attic/.classpath delete mode 100644 aspectj-attic/.project delete mode 100644 aspectj-attic/ajdoc-src/devnotes.txt delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/ajdoc/AdviceDoc.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/ajdoc/AspectDoc.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/ajdoc/ClassDoc.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/ajdoc/ConstructorDoc.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/ajdoc/Doc.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/ajdoc/ExecutableMemberDoc.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/ajdoc/FieldDoc.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/ajdoc/IntroducedDoc.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/ajdoc/IntroducedSuperDoc.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/ajdoc/IntroductionDoc.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/ajdoc/MemberDoc.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/ajdoc/MethodDoc.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/ajdoc/OfClauseDoc.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/ajdoc/OfEachObjectDoc.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/ajdoc/PackageDoc.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/ajdoc/ParamTag.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/ajdoc/Parameter.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/ajdoc/PointcutDoc.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/ajdoc/ProgramElementDoc.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/ajdoc/RootDoc.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/ajdoc/SeeTag.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/ajdoc/SerialFieldTag.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/ajdoc/Tag.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/ajdoc/ThrowsTag.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/ajdoc/Type.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/Access.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/AccessChecker.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/AdviceDocImpl.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/Ajdoc.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/AjdocCompiler.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/AspectDocImpl.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/CannotMakeRootDocException.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/ClassDocImpl.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/CodeDocImpl.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/Comment.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/ConstructorDocImpl.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/DocImpl.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/DocletProxy.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/ErrPrinter.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/ExecutableMemberDocImpl.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/FieldDocImpl.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/FilteredDecList.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/IntroducedDocImpl.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/IntroducedSuperDocImpl.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/IntroductionDocImpl.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/Main.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/MemberDocImpl.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/MethodDocImpl.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/OfClauseDocImpl.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/PackageDocImpl.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/ParamTagImpl.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/ParameterImpl.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/PointcutDocImpl.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/ProgramElementDocImpl.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/Quietable.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/RootDocImpl.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/RootDocMaker.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/SeeTagImpl.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/SerialFieldTagImpl.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/TagImpl.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/ThrowsTagImpl.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/TypeImpl.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/Util.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/resources/ajdoc.properties delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/rootmakers/Javadoc.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/rootmakers/Javadoc13.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/rootmakers/Javadoc14.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/AbstractIndexWriter.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/AbstractStandard.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/AbstractSubWriter.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/AbstractSubWriterAJ.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/AbstractTreeWriter.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/AdviceSubWriter.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/ClassSubWriter.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/ClassUseMapper.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/ClassUseWriter.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/ClassWriter.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/ConfigurationStandard.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/ConstructorIntroductionSubWriter.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/ConstructorSubWriter.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/DeprecatedAPIListBuilder.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/DeprecatedListWriter.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/ExecutableMemberSubWriter.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/FieldIntroductionSubWriter.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/FieldSubWriter.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/MethodIntroductionSubWriter.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/MethodSubWriter.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/PackageFrameWriter.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/PackageTreeWriter.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/PackageWriter.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/PointcutSubWriter.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/SingleIndexWriter.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/SplitIndexWriter.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/Standard.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/Statics.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/SubWriterHolderWriter.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/SuperIntroductionSubWriter.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/TreeWriter.java delete mode 100644 aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/resources/standard.properties delete mode 100644 aspectj-attic/ajdoc-testsrc/AjdocModuleTests.java delete mode 100644 aspectj-attic/ajdoc-testsrc/org/aspectj/tools/ajdoc/AjdocTests.java delete mode 100644 aspectj-attic/ajdoc-testsrc/org/aspectj/tools/ajdoc/JUnitDriver.java delete mode 100644 aspectj-attic/ajdoc-testsrc/org/aspectj/tools/ajdoc/SeeTagImplTest.java delete mode 100644 aspectj-attic/ajdoc-testsrc/org/aspectj/tools/ajdoc/genSeeTestCases.sh delete mode 100644 aspectj-attic/readme-aspectj-attic-module.html delete mode 100644 aspectj-attic/testing-src/AjcTaskTester.java delete mode 100644 aspectj-attic/testing-src/AjcTaskTester2.java delete mode 100644 aspectj-attic/testing-src/AjdocTaskTester.java delete mode 100644 aspectj-attic/testing-src/AntTaskTester.java delete mode 100644 aspectj-attic/testing-src/org/aspectj/testing/compare/CompareFiles.java delete mode 100644 aspectj-attic/testing-src/org/aspectj/testing/compare/CompareUtil.java delete mode 100644 aspectj-attic/testing-src/org/aspectj/testing/compare/GenericTreeNode.java delete mode 100644 aspectj-attic/testing-src/org/aspectj/testing/compare/GenericTreeNodeListOrdererFactoryI.java delete mode 100644 aspectj-attic/testing-src/org/aspectj/testing/compare/GenericTreeNodeListOrdererI.java delete mode 100644 aspectj-attic/testing-src/org/aspectj/testing/compare/GenericTreeNodesVisitorI.java delete mode 100644 aspectj-attic/testing-src/org/aspectj/testing/compare/Regexp.java delete mode 100644 aspectj-attic/testing-src/org/aspectj/testing/compare/RegexpFactory.java delete mode 100644 aspectj-attic/testing-src/org/aspectj/testing/compare/RegexpFilter.java delete mode 100644 aspectj-attic/testing-src/org/aspectj/testing/compare/RegexpFilterReader.java delete mode 100644 aspectj-attic/testing-src/org/aspectj/testing/compare/TreeCompare.java delete mode 100644 aspectj-attic/testing-src/org/aspectj/testing/compare/adapters/GenericTreeNodeFactoryI.java delete mode 100644 aspectj-attic/testing-src/org/aspectj/testing/compare/adapters/JTreeNodeGenericTreeNodeFactory.java delete mode 100644 aspectj-attic/testing-src/org/aspectj/testing/compare/adapters/Structure.java delete mode 100644 aspectj-attic/testing-src/org/aspectj/testing/compare/adapters/StructureGenericTreeNodeFactory.java delete mode 100644 aspectj-attic/testing-src/org/aspectj/testing/compare/adapters/SubTypeComparator.java delete mode 100644 aspectj-attic/testing-src/org/aspectj/testing/compare/adapters/package.html delete mode 100644 aspectj-attic/testing-src/org/aspectj/testing/compare/package.html delete mode 100644 aspectj-attic/testing-src/org/aspectj/testing/taskdefs/CompareFiles.java delete mode 100644 aspectj5rt/.classpath delete mode 100644 aspectj5rt/.cvsignore delete mode 100644 aspectj5rt/.project delete mode 100644 aspectj5rt/.settings/org.eclipse.jdt.core.prefs delete mode 100644 aspectj5rt/aspectj5rt.mf.txt delete mode 100644 aspectj5rt/build.xml delete mode 100644 aspectj5rt/java5-src/org/aspectj/internal/lang/annotation/ajcDeclareAnnotation.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/internal/lang/annotation/ajcDeclareEoW.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/internal/lang/annotation/ajcDeclareParents.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/internal/lang/annotation/ajcDeclarePrecedence.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/internal/lang/annotation/ajcDeclareSoft.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/internal/lang/annotation/ajcITD.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/internal/lang/annotation/ajcPrivileged.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/AdviceImpl.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/AjTypeImpl.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/DeclareAnnotationImpl.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/DeclareErrorOrWarningImpl.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/DeclareParentsImpl.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/DeclarePrecedenceImpl.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/DeclareSoftImpl.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/InterTypeConstructorDeclarationImpl.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/InterTypeDeclarationImpl.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/InterTypeFieldDeclarationImpl.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/InterTypeMethodDeclarationImpl.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/PerClauseImpl.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/PointcutBasedPerClauseImpl.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/PointcutExpressionImpl.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/PointcutImpl.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/SignaturePatternImpl.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/StringToType.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/TypePatternBasedPerClauseImpl.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/TypePatternImpl.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/Aspects.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/annotation/AdviceName.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/annotation/After.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/annotation/AfterReturning.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/annotation/AfterThrowing.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/annotation/Around.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/annotation/Aspect.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/annotation/Before.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareAnnotation.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareError.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareMixin.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareParents.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclarePrecedence.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareWarning.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/annotation/Pointcut.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/annotation/RequiredTypes.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/annotation/SuppressAjWarnings.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/annotation/control/CodeGenerationHint.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/reflect/Advice.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/reflect/AdviceKind.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/reflect/AjType.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/reflect/AjTypeSystem.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/reflect/DeclareAnnotation.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/reflect/DeclareErrorOrWarning.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/reflect/DeclareParents.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/reflect/DeclarePrecedence.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/reflect/DeclareSoft.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/reflect/InterTypeConstructorDeclaration.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/reflect/InterTypeDeclaration.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/reflect/InterTypeFieldDeclaration.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/reflect/InterTypeMethodDeclaration.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/reflect/NoSuchAdviceException.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/reflect/NoSuchPointcutException.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/reflect/PerClause.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/reflect/PerClauseKind.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/reflect/Pointcut.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/reflect/PointcutBasedPerClause.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/reflect/PointcutExpression.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/reflect/SignaturePattern.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/reflect/TypePattern.java delete mode 100644 aspectj5rt/java5-src/org/aspectj/lang/reflect/TypePatternBasedPerClause.java delete mode 100644 aspectj5rt/java5-testsrc/Aspectj5rt15ModuleTests.java delete mode 100644 aspectj5rt/java5-testsrc/org/aspectj/internal/lang/reflect/AjTypeTests.java delete mode 100644 aspectj5rt/java5-testsrc/org/aspectj/internal/lang/reflect/AjTypeTestsWithAspects.java delete mode 100644 aspectj5rt/java5-testsrc/org/aspectj/internal/lang/reflect/InterTypeTests.java delete mode 100644 aspectj5rt/src/org/aspectj/lang/internal/lang/PlaceHolder.java delete mode 100644 aspectj5rt/testsrc/org/aspectj/runtime/Aspectj5rtModuleTests.java create mode 100644 aspectjtools/aspectjtools-assembly.xml create mode 100644 aspectjtools/aspectjtools-sources-assembly.xml create mode 100644 aspectjtools/pom.xml delete mode 100644 docs/.project delete mode 100644 loadtime5/.classpath delete mode 100644 loadtime5/.cvsignore delete mode 100644 loadtime5/.project delete mode 100644 loadtime5/.settings/org.eclipse.jdt.core.prefs delete mode 100644 loadtime5/build.xml delete mode 100644 loadtime5/java5-src/org/aspectj/weaver/loadtime/Agent.java delete mode 100644 loadtime5/java5-src/org/aspectj/weaver/loadtime/ClassPreProcessorAgentAdapter.java delete mode 100644 loadtime5/java5-testsrc/Loadtime515ModuleTests.java delete mode 100644 loadtime5/java5-testsrc/org/aspectj/weaver/loadtime/LoadtimeTests.java delete mode 100644 loadtime5/loadtime5.mf.txt delete mode 100644 loadtime5/testsrc/org/aspectj/loadtime/Loadtime5ModuleTests.java delete mode 100644 weaver5/.classpath delete mode 100644 weaver5/.cvsignore delete mode 100644 weaver5/.project delete mode 100644 weaver5/.settings/org.eclipse.jdt.core.prefs delete mode 100644 weaver5/.settings/org.eclipse.jdt.ui.prefs delete mode 100644 weaver5/build.xml delete mode 100644 weaver5/java5-src/org/aspectj/weaver/reflect/ArgNameFinder.java delete mode 100644 weaver5/java5-src/org/aspectj/weaver/reflect/DeferredResolvedPointcutDefinition.java delete mode 100644 weaver5/java5-src/org/aspectj/weaver/reflect/InternalUseOnlyPointcutParser.java delete mode 100644 weaver5/java5-src/org/aspectj/weaver/reflect/Java15AnnotationFinder.java delete mode 100644 weaver5/java5-src/org/aspectj/weaver/reflect/Java15GenericSignatureInformationProvider.java delete mode 100644 weaver5/java5-src/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java delete mode 100644 weaver5/java5-src/org/aspectj/weaver/reflect/JavaLangTypeToResolvedTypeConverter.java delete mode 100644 weaver5/java5-src/org/aspectj/weaver/tools/Jdk14Trace.java delete mode 100644 weaver5/java5-src/org/aspectj/weaver/tools/Jdk14TraceFactory.java delete mode 100644 weaver5/java5-testsrc/$Proxy1.java delete mode 100644 weaver5/java5-testsrc/CounterAspect.java delete mode 100644 weaver5/java5-testsrc/GenericService.java delete mode 100644 weaver5/java5-testsrc/MA.java delete mode 100644 weaver5/java5-testsrc/MB.java delete mode 100644 weaver5/java5-testsrc/MC.java delete mode 100644 weaver5/java5-testsrc/MD.java delete mode 100644 weaver5/java5-testsrc/MessageService.java delete mode 100644 weaver5/java5-testsrc/org/aspectj/matcher/tools/ReflectionWorldAdvancedPointcutExpressionTests.java delete mode 100644 weaver5/java5-testsrc/org/aspectj/weaver/AllTracing5Tests.java delete mode 100644 weaver5/java5-testsrc/org/aspectj/weaver/AllWeaver5Tests.java delete mode 100644 weaver5/java5-testsrc/org/aspectj/weaver/BcweaverModuleTests15.java delete mode 100644 weaver5/java5-testsrc/org/aspectj/weaver/BoundedReferenceTypeTestCase.java delete mode 100644 weaver5/java5-testsrc/org/aspectj/weaver/CommonReferenceTypeTests.java delete mode 100644 weaver5/java5-testsrc/org/aspectj/weaver/Jdk14TraceFactoryTest.java delete mode 100644 weaver5/java5-testsrc/org/aspectj/weaver/Jdk14TraceTest.java delete mode 100644 weaver5/java5-testsrc/org/aspectj/weaver/JoinPointSignatureIteratorTests.java delete mode 100644 weaver5/java5-testsrc/org/aspectj/weaver/MemberTestCase15.java delete mode 100644 weaver5/java5-testsrc/org/aspectj/weaver/ReferenceTypeTestCase.java delete mode 100644 weaver5/java5-testsrc/org/aspectj/weaver/TestJava5ReflectionBasedReferenceTypeDelegate.java delete mode 100644 weaver5/java5-testsrc/org/aspectj/weaver/TypeVariableReferenceTypeTestCase.java delete mode 100644 weaver5/java5-testsrc/org/aspectj/weaver/TypeVariableTestCase.java delete mode 100644 weaver5/java5-testsrc/org/aspectj/weaver/bcel/BcelGenericSignatureToTypeXTestCase.java delete mode 100644 weaver5/java5-testsrc/org/aspectj/weaver/bcel/BcelWorldReferenceTypeTest.java delete mode 100644 weaver5/java5-testsrc/org/aspectj/weaver/patterns/WildTypePatternResolutionTestCase.java delete mode 100644 weaver5/java5-testsrc/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateTest.java delete mode 100644 weaver5/java5-testsrc/org/aspectj/weaver/reflect/ReflectionWorldReferenceTypeTest.java delete mode 100644 weaver5/java5-testsrc/org/aspectj/weaver/reflect/ReflectionWorldTest.java delete mode 100644 weaver5/java5-testsrc/org/aspectj/weaver/tools/Java15PointcutExpressionTest.java delete mode 100644 weaver5/java5-testsrc/test/A.java delete mode 100644 weaver5/java5-testsrc/test/A1.java delete mode 100644 weaver5/java5-testsrc/test/A1AnnotatedType.java delete mode 100644 weaver5/java5-testsrc/test/A2.java delete mode 100644 weaver5/java5-testsrc/test/A2AnnotatedType.java delete mode 100644 weaver5/java5-testsrc/test/A3.java delete mode 100644 weaver5/java5-testsrc/test/AnnoValues.java delete mode 100644 weaver5/java5-testsrc/test/Color.java delete mode 100644 weaver5/testdata/logging.properties delete mode 100644 weaver5/testsrc/org/aspectj/weaver/Weaver5ModuleTests.java diff --git a/README.md b/README.md new file mode 100644 index 000000000..75722df9c --- /dev/null +++ b/README.md @@ -0,0 +1,24 @@ +# AspectJ + + +## Building + +AspectJ has a multi module maven build. Although various modules produce intermediate results, the key artifacts at the end of the build are: + +* `aspectjrt` - the AspectJ runtime +* `aspectjweaver` - the AspectJ weaver +* `aspectjtools` - the AspectJ compiler + +These are the artifacts published to maven central for each release. In addition there is an installer that can be run with `java -jar` to install AspectJ onto Windows/Mac/Linux. This installer is produced by the installer sub module. + +In the root of a cloned AspectJ simply run: + +`./mvnw clean install` + +This will build all the modules, run all the tests and install the key artifacts in your local repository. + +## Running the tests in eclipse + +Once you have imported all the projects using `m2e`, there is a special module called `run-all-junit-tests` and within that a `RunTheseBeforeYouCommitTests` class that can be run with the JUnit launcher. This will execute all the tests in each module plus the compiler tests in the `tests` module. + + \ No newline at end of file diff --git a/README.txt b/README.txt deleted file mode 100644 index 139597f9c..000000000 --- a/README.txt +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/aspectj-attic/.classpath b/aspectj-attic/.classpath deleted file mode 100644 index e451f516e..000000000 --- a/aspectj-attic/.classpath +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/aspectj-attic/.project b/aspectj-attic/.project deleted file mode 100644 index 844fe4c64..000000000 --- a/aspectj-attic/.project +++ /dev/null @@ -1,19 +0,0 @@ - - - aspectj-attic - - - testing - util - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/aspectj-attic/ajdoc-src/devnotes.txt b/aspectj-attic/ajdoc-src/devnotes.txt deleted file mode 100644 index 5958dfbc2..000000000 --- a/aspectj-attic/ajdoc-src/devnotes.txt +++ /dev/null @@ -1,98 +0,0 @@ - --------------- Problems: - ----- todo FIX output HTML is using "introduction" as labels. -- use "[Summary|Details] of [fields|methods|constructors] declared for target types" - ("target" rather than "other" since they may be defined on self?) -- see also top index links: - - super introductions... - -solution: change doclet resources - ----- FIXED comments not displayed for inter-type declarations in the aspects -solution: IntroducedDocImpl.java sets source location for the dec from the introduced dec - -> dec.setSourceLocation(introducedDec.getSourceLocation()); // PR790, 712 - - ----- PARTIAL FIX: synthetic constructors are shown in the javadoc -solution: post-process to remove unadvised constructors with same source location as parent class - -See ClassDocImpl.java - -problem with the solution: does not remove synthetic constructors on aspects?? - (only if they advise themselves?) - - ----- FIXED class cast exception trying to print introduced Constructor parameters -solution: -diff -r1.5 IntroducedDocImpl.java -105c107 -< makeParameters(((MethodDocImpl)cs[i]). ---- -> makeParameters(((ConstructorDocImpl)cs[i]). - ----- introduced constructor names use the name of the declaring aspect, not the target -solution: -diff -r1.4 ConstructorDocImpl.java -53c56,58 -< return containingClass().name(); ---- -> String qname = getQualifiedName(); -> return (null != qname ? qname : containingClass().name()); - ----- ok: in aspect docs, inter-type declarations targeting the aspect work as expected, - with both the inter-type declaration and the aspect-declared member documented. - ----- ajc prints out declare-warnings when compiling for ajdoc - ----- in aspect docs, links out to affected classes not printed for introduced constructors -essentially, the name of the constructor (should) differ for each target. sigh. -- identifier should be the FQN of the aspect plus the type pattern and signature of the constructor. - (parm signature - result, throws not required) -- display label in the aspect should be the identifier - -> currently is the name of the aspect plus () -- display label in affected classes should be the name of the affected class and the parm signature - -> c - ----- in target docs, links back to declaring aspects for introduced constructors fail -(iff parms?) - ----- in target docs, summaries of members declared by aspects do not list initial comment line. - ----- is aspect docs, members declared on target types are displayed only with the member name, - not the typepattern. -see IntroducedDocImpl.java name() - - public String name() { - // when using qualified name, unable to find links aout to targets - // return (null != qualifiedName ? qualifiedName : dec().getId()); // XXX - // when using id, only get simple name - return dec().getId(); - } - ==> get caller to use printedName as label - -UNFIXABLE - caller is sun doclet, and we only give it the member as parameter. -We do control the names of the links out, but not the name of the member in the class, -except to override qualifiedName, which causes the links out to fail (because -IntroducedDocImpl.createTargets() uses MemberDocImpl.weakEquals() to discover -all introduced members in other types to find out if they were introduced by this -declaration (awful!), and [Method|Field|Member]DocImpl.weakEquals() implementations -use name() - using qualifiedName() would result in false positives for any field -in a target class). Overriding name() also causes other things to fail because it is -used as an id. Even changing the name during the lifecycle seems risky. There's -not a clean separation between the type name and the name as displayed. - ----- in target class docs, introduced member links back to declaring aspect - have the member name as their label; should have the aspect type. - ----- bad fix: references to declaration targets lost and incomplete html thereafter - is a result of modifying name() or qualifiedName() of memberDoc - --------------- Background: -?? -declaration target - Introduced -declaration source - Introduction - - - diff --git a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/AdviceDoc.java b/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/AdviceDoc.java deleted file mode 100644 index 1abf7dff7..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/AdviceDoc.java +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.ajdoc; - -import com.sun.javadoc.Type; - -/** - * Documentation for a piece of advice. - * - * @author Jeff Palm - */ -public interface AdviceDoc extends ExecutableMemberDoc, - com.sun.javadoc.ExecutableMemberDoc { - /** - * Returns true if the advice is abstract. - * - * @return true if the advice is abstract. - */ - public boolean isAbstract(); - - /** - * Returns a {@link #AspectDoc} representing the aspect - * that is overriden by this advice. - * - * @return a AspectDoc representing the aspect - * that is overriden by this advice. - */ - public AspectDoc overriddenAspect(); - - /** - * Returns the return type of this advice -- it may be null. - * - * @return the return type of this advice -- it may be null. - */ - public Type returnType(); - - /** - * Returns the array of docs this advice crosscuts. - * - * @return an array of docs this advice crosscuts. - */ - public com.sun.javadoc.ExecutableMemberDoc[] crosscuts(); - - /** - * Returns true if this is throwing advice. - * - * @return true if this is throwing advice. - */ - public boolean isThrowing(); - - /** - * Returns true if this is returning advice. - * - * @return true if this is returning advice. - */ - public boolean isReturning(); - - /** - * Returns the extra formal type that's the optional type - * to after returning or after throwing - * advice. - * - * @return an instance of Type that represents the the extra formal type - * that's the optional type to after returning or - * after throwing advice. - */ - public Type extraType(); -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/AspectDoc.java b/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/AspectDoc.java deleted file mode 100644 index 0ead3a197..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/AspectDoc.java +++ /dev/null @@ -1,83 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.ajdoc; - -/** - * Represents an aspectj aspect and extends - * ClassDoc to provide the extra aspectj-only - * information not present in that interface. - * - * @author Jeff Palm - */ -public interface AspectDoc extends ClassDoc { //, com.sun.javadoc.ClassDoc { - - /** - * Return advice in aspect. - * - * @return an array of AdviceDoc for representing the - * visible advice in this aspect. - */ - public AdviceDoc[] advice(); - - /** - * Return aspects that are dominated by this aspect. - * - * @return an array of AspectDoc for representing the - * aspects that are dominated by this aspect. - */ - public AspectDoc[] dominatees(); - - /** - * Return aspects that dominate this aspect. - * - * @return an array of AspectDoc for representing the - * aspects that dominate this aspect. - */ - public AspectDoc[] dominators(); - - /** - * Return the introductions made by this aspect on other types. - * - * @return an array of IntroductionDoc for representing the - * introductions made on other types. - */ - public IntroductionDoc[] introductions(); - - /** - * Return the of clauses that describe this aspect. - * - * @return an array of OfClauseDoc for representing the - * of clauses that describe this aspect. - */ - public OfClauseDoc ofClause(); - - /** - * Returns true if this aspects dominates - * the passed in aspect. - * - * @param other an AspectDoc that represents another - * aspect in this world. - * @return true if this aspects dominates - * the passed in aspect. - */ - public boolean dominates(AspectDoc other); -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/ClassDoc.java b/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/ClassDoc.java deleted file mode 100644 index eff5fa103..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/ClassDoc.java +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.ajdoc; - -/** - * Represents a class in the aspectj-world. The difference - * between this and one in the javac-world, is that a class - * may have pointcuts and introductions. - * - * @author Jeff Palm - */ -public interface ClassDoc extends com.sun.javadoc.ClassDoc, - ProgramElementDoc, Type { - - /** - * Returns the pointcuts this class declares. - * - * @return an array of PointcutDoc representing the - * pointcuts declared by this class. - */ - public PointcutDoc[] pointcuts(); - - /** - * Returns the introductions made by other aspects that - * affect the type hierarchy of this class. - * - * @return an array of IntroducedSuperDoc representing the - * introductions affecting the type hierarchy of - * this class. - */ - public IntroducedSuperDoc[] introducers(); - - /** - * Return true if this is an aspect. - * - * @return true is this is an aspect. - */ - public boolean isAspect(); -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/ConstructorDoc.java b/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/ConstructorDoc.java deleted file mode 100644 index 3557fe025..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/ConstructorDoc.java +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.ajdoc; - -/** - * An empty extension of com.sun.javadoc.ConstructorDoc. - * - * @author Jeff Palm - */ -public interface ConstructorDoc extends com.sun.javadoc.ConstructorDoc, - ExecutableMemberDoc { -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/Doc.java b/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/Doc.java deleted file mode 100644 index 95fc2514b..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/Doc.java +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.ajdoc; - -/** - * The abstract base class of all Doc classes in the - * aspectj-world. - * - * @author Jeff Palm - */ -public interface Doc extends com.sun.javadoc.Doc { - - /** - * Returns true if this Doc is advice. - * - * @return true is this Doc is advice. - */ - public boolean isAdvice(); - - /** - * Returns true if this Doc is a pointcut. - * - * @return true is this Doc is a pointcut. - */ - public boolean isPointcut(); -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/ExecutableMemberDoc.java b/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/ExecutableMemberDoc.java deleted file mode 100644 index 7af271f8c..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/ExecutableMemberDoc.java +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.ajdoc; - -/** - * Represents and executable member in the aspectj-world. - * The only difference between this and one in the javac-world - * is that these members can have advice on them - * - * @author Jeff Palm - */ -public interface ExecutableMemberDoc extends com.sun.javadoc.ExecutableMemberDoc, - MemberDoc { - - /** - * Returns the advice placed on this member. - * - * @return an array of AdviceDoc representing the - * advice placed on this member. - */ - public AdviceDoc[] advice(); -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/FieldDoc.java b/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/FieldDoc.java deleted file mode 100644 index 5997df375..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/FieldDoc.java +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.ajdoc; - -/** - * An empty extension of com.sun.javadoc.FieldDoc. - * - * @author Jeff Palm - */ -public interface FieldDoc extends com.sun.javadoc.FieldDoc, MemberDoc { -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/IntroducedDoc.java b/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/IntroducedDoc.java deleted file mode 100644 index 3f3f6ac1c..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/IntroducedDoc.java +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.ajdoc; - -/** - * Represents the introduction of a member onto a ClassDoc. - * - * @author Jeff Palm - */ -public interface IntroducedDoc extends IntroductionDoc { - - /** - * Returns the member introduced on {@link #targets()}. - * - * @return the MemberDoc that was introduced. - */ - public MemberDoc member(); -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/IntroducedSuperDoc.java b/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/IntroducedSuperDoc.java deleted file mode 100644 index 855b13786..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/IntroducedSuperDoc.java +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.ajdoc; - -/** - * Represents the introduction of a class-extension or - * interface-implementation (e.g. +extends or +implements) - * onto a ClassDoc. - * - * @author Jeff Palm - */ -public interface IntroducedSuperDoc extends IntroductionDoc { - - /** - * Returns the types that are introduced. - * - * @return an array of Type representing the classes or - * aspects that the target ClassDocs now implement - * or extend. - */ - public Type[] types(); - - /** - * Returns true is this is a '+implements' - * introduction. - * - * @return true is this is a '+implements' - * introduction. - */ - public boolean isImplements(); -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/IntroductionDoc.java b/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/IntroductionDoc.java deleted file mode 100644 index a2e4efe4d..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/IntroductionDoc.java +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.ajdoc; - -/** - * Represents an introduction with >= 0 target ClassDocs. - * - * @author Jeff Palm - */ -public interface IntroductionDoc extends MemberDoc { - - /** - * Returns the targets that this introduction affects. - * - * @return an array of ClassDoc representing the - * classes/aspects this introduction affects. - */ - public ClassDoc[] targets(); -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/MemberDoc.java b/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/MemberDoc.java deleted file mode 100644 index e793d929f..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/MemberDoc.java +++ /dev/null @@ -1,43 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.ajdoc; - -/** - * A class or aspect member in the aspectj-world, the difference - * between this and a javac-world member is that if this member - * was introduced by an aspect, it has a reference to that - * introduction. - * - * @author Jeff Palm - */ -public interface MemberDoc extends com.sun.javadoc.MemberDoc, - ProgramElementDoc { - - /** - * Returns the introduction that placed this member on this class - * if is exists -- this can be null. - * - * @return the introduction that placed this member on this class - * if is exists -- this can be null. - */ - public IntroducedDoc introduced(); -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/MethodDoc.java b/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/MethodDoc.java deleted file mode 100644 index 0d05b0d79..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/MethodDoc.java +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.ajdoc; - -/** - * An empty exntension to com.sun.javadoc.MethodDoc. - * - * @author Jeff Palm - */ -public interface MethodDoc extends com.sun.javadoc.MethodDoc, - ExecutableMemberDoc { - -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/OfClauseDoc.java b/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/OfClauseDoc.java deleted file mode 100644 index 776d1bce6..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/OfClauseDoc.java +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.ajdoc; - -/** - * Represents an of clause describing an aspect. - * This declaration also contains constants to be used to - * identify different OfClauseDocs. - * - * @author Jeff Palm - */ -public interface OfClauseDoc { - - /** - * A typesafe-enum describing the possible kinds - * of OfClauseDocs. - */ - public final static class Kind { - - /** Internal representation. */ - private final String kind; - - /** - * Don't allow any other's to call this. - * - * @param kind The internal String representation. - */ - private Kind(String kind) { this.kind = kind; } - - /** - * Represents an 'of eachcflow(..)' clause. - */ - public final static Kind EACH_CFLOW = new Kind("echocflow(..)"); - - /** - * Represents an 'of eachJVM()' clause. - */ - public final static Kind EACH_JVM = new Kind("eachJVM()"); - - /** - * Represents an 'of eachobject(..)' clause. - */ - public final static Kind EACH_OBJECT = new Kind("eachObject()"); - - /** - * Returns a short representation of the kind. - * - * @return a short representation of the kind. - */ - public String toString() { return kind; } - } - - /** - * Returns the appropriate constant defined in Kind. - * - * @return the appropriate constant defined in Kind. - * @see Kind - */ - public Kind kind(); -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/OfEachObjectDoc.java b/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/OfEachObjectDoc.java deleted file mode 100644 index bc05a777b..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/OfEachObjectDoc.java +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.ajdoc; - -/** - * Representat an 'of eachobject(..)' clause, thought currently - * out of the language, it could make a comeback. - * - * @author Jeff Palm - */ -public interface OfEachObjectDoc extends OfClauseDoc { - - /** - * Returns the classes for which an instance of - * this aspect will be made for each. - * - * @return an array of com.sun.javadoc.ClassDoc representing - * the classes for which an instance of - * this aspect will be made for each. - */ - //public com.sun.javadoc.ClassDoc[] instances(); - public ClassDoc[] instances(); -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/PackageDoc.java b/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/PackageDoc.java deleted file mode 100644 index a34cc508a..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/PackageDoc.java +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.ajdoc; - -/** - * An extension of com.sun.javadoc.PackageDoc to add aspects. - * - * @author Jeff Palm - */ -public interface PackageDoc extends com.sun.javadoc.PackageDoc, - Doc -{ - - /** - * Returns the aspects in this package. - * - * @return an array of AspectDoc representing the - * aspects in this package. - */ - public AspectDoc[] aspects(); -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/ParamTag.java b/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/ParamTag.java deleted file mode 100644 index 9b9bc1513..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/ParamTag.java +++ /dev/null @@ -1,24 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.ajdoc; - -public interface ParamTag extends com.sun.javadoc.ParamTag {} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/Parameter.java b/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/Parameter.java deleted file mode 100644 index 140b5ddd0..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/Parameter.java +++ /dev/null @@ -1,24 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.ajdoc; - -public interface Parameter extends com.sun.javadoc.Parameter {} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/PointcutDoc.java b/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/PointcutDoc.java deleted file mode 100644 index 0883271e1..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/PointcutDoc.java +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.ajdoc; - -import com.sun.javadoc.ClassDoc; - -import com.sun.javadoc.Type; - -/** - * Represents a pointcut in the aspectj-world. - * - * @author Jeff Palm - */ -public interface PointcutDoc extends ExecutableMemberDoc, - com.sun.javadoc.ExecutableMemberDoc -{ - /** - * Returns the resulting type of this pointcut. - * - * @return an instance of Type representing the type - * this pointcut returns. - */ - public Type resultType(); - - /** - * The nearest class in which this pointcut was defined. - * - * @return an instanceof ClassDoc representing the - * nearst class in which this pointcut was - * defined. - */ - public ClassDoc overriddenClass(); - - /** - * Returns true if this pointcut - * is abstract. - * - * @return true if this pointcut - * is abstract. - */ - public boolean isAbstract(); -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/ProgramElementDoc.java b/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/ProgramElementDoc.java deleted file mode 100644 index 5ef9f84e7..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/ProgramElementDoc.java +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.ajdoc; - -/** - * An empty extension of com.sun.javadoc.ProgramElementDoc. - * - * @author Jeff Palm - */ -public interface ProgramElementDoc extends com.sun.javadoc.ProgramElementDoc, - Doc { -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/RootDoc.java b/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/RootDoc.java deleted file mode 100644 index 6a80ee40e..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/RootDoc.java +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.ajdoc; - -/** - * An empty extension of com.sun.javadoc.RootDoc. - * - * @author Jeff Palm - */ -public interface RootDoc extends com.sun.javadoc.RootDoc, - Doc { -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/SeeTag.java b/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/SeeTag.java deleted file mode 100644 index 69add72e2..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/SeeTag.java +++ /dev/null @@ -1,24 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.ajdoc; - -public interface SeeTag extends com.sun.javadoc.SeeTag {} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/SerialFieldTag.java b/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/SerialFieldTag.java deleted file mode 100644 index 078cbb873..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/SerialFieldTag.java +++ /dev/null @@ -1,24 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.ajdoc; - -public interface SerialFieldTag extends com.sun.javadoc.SerialFieldTag {} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/Tag.java b/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/Tag.java deleted file mode 100644 index bacd8b8ba..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/Tag.java +++ /dev/null @@ -1,24 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.ajdoc; - -public interface Tag extends com.sun.javadoc.Tag {} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/ThrowsTag.java b/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/ThrowsTag.java deleted file mode 100644 index 419e779b6..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/ThrowsTag.java +++ /dev/null @@ -1,24 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.ajdoc; - -public interface ThrowsTag extends com.sun.javadoc.ThrowsTag {} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/Type.java b/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/Type.java deleted file mode 100644 index 4ffdccbdf..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/ajdoc/Type.java +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.ajdoc; - -/** - * An empty extension of com.sun.javadoc.RootDoc. - * - * @author Jeff Palm - */ -public interface Type extends com.sun.javadoc.Type { - -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/Access.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/Access.java deleted file mode 100644 index e3379189c..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/Access.java +++ /dev/null @@ -1,197 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -//package com.sun.tools.doclets.standard; -package org.aspectj.tools.ajdoc; - -import org.aspectj.tools.doclets.standard.AbstractSubWriter; - -import com.sun.javadoc.ClassDoc; -import com.sun.javadoc.Doc; -import com.sun.javadoc.ExecutableMemberDoc; -import com.sun.javadoc.ProgramElementDoc; -import com.sun.tools.doclets.standard.ClassUseWriter; -import com.sun.tools.doclets.standard.ExecutableMemberSubWriter; -import com.sun.tools.doclets.standard.SubWriterHolderWriter; - -import java.util.List; -import java.util.SortedSet; - -/** - * Allows for access to protected and package-protected (OK - * sometimes private) members in classes in the package - * com.sun.tools.doclets... - * - * @author Jeff Palm - */ -public class Access { - - public static void printSummaryType(AbstractSubWriter mw, - ProgramElementDoc member) { - Util.invoke(com.sun.tools.doclets.standard.AbstractSubWriter.class, - mw.del(), - "printSummaryType", - new Class[]{ProgramElementDoc.class}, - new Object[]{member}); - } - public static void printSummaryLink(AbstractSubWriter mw, - ClassDoc cd, - ProgramElementDoc member) { - Util.invoke(com.sun.tools.doclets.standard.AbstractSubWriter.class, - mw.del(), - "printSummaryLink", - new Class[]{ClassDoc.class, - ProgramElementDoc.class}, - new Object[]{cd, member}); - } - public static void printInheritedSummaryLink(AbstractSubWriter mw, - ClassDoc cd, - ProgramElementDoc member) { - Util.invoke(com.sun.tools.doclets.standard.AbstractSubWriter.class, - mw.del(), - "printInheritedSummaryLink", - new Class[]{ClassDoc.class, - ProgramElementDoc.class}, - new Object[]{cd, member}); - } - public static void printHeader(AbstractSubWriter mw, - ClassDoc cd) { - Util.invoke(com.sun.tools.doclets.standard.AbstractSubWriter.class, - mw.del(), - "printHeader", - new Class[]{ClassDoc.class}, - new Object[]{cd}); - } - public static void printBodyHtmlEnd(AbstractSubWriter mw, - ClassDoc cd) { - Util.invoke(com.sun.tools.doclets.standard.AbstractSubWriter.class, - mw.del(), - "printBodyHtmlEnd", - new Class[]{ClassDoc.class}, - new Object[]{cd}); - } - public static void printMember(AbstractSubWriter mw, - ProgramElementDoc elem) { - Util.invoke(com.sun.tools.doclets.standard.AbstractSubWriter.class, - mw.del(), - "printMember", - new Class[]{ProgramElementDoc.class}, - new Object[]{elem}); - } - public static void printDeprecatedLink(AbstractSubWriter mw, - ProgramElementDoc member) { - Util.invoke(com.sun.tools.doclets.standard.AbstractSubWriter.class, - mw.del(), - "printDeprecatedLink", - new Class[]{ProgramElementDoc.class}, - new Object[]{member}); - } - public static void printNavSummaryLink(AbstractSubWriter mw, - ClassDoc cd, - boolean link) { - Util.invoke(com.sun.tools.doclets.standard.AbstractSubWriter.class, - mw.del(), - "printNavSummaryLink", - new Class[]{ClassDoc.class, - boolean.class}, - new Object[]{cd, new Boolean(link)}); - } - public static void printNavDetailLink(AbstractSubWriter mw, - boolean link) { - Util.invoke(com.sun.tools.doclets.standard.AbstractSubWriter.class, - mw.del(), - "printNavDetailLink", - new Class[]{boolean.class}, - new Object[]{new Boolean(link)}); - } - public static void printTags(AbstractSubWriter mw, - ProgramElementDoc member) { - Util.invoke(com.sun.tools.doclets.standard.AbstractSubWriter.class, - mw.del(), - "printTags", - new Class[]{ProgramElementDoc.class}, - new Object[]{member}); - } - public static void printDeprecatedAPI(AbstractSubWriter mw, - List deprmembers, - String headingKey) { - Util.invoke(com.sun.tools.doclets.standard.AbstractSubWriter.class, - mw.del(), - "printDeprecatedAPI", - new Class[]{List.class, String.class}, - new Object[]{deprmembers, headingKey}); - } - public static void printParameters(ExecutableMemberSubWriter mw, - ExecutableMemberDoc member) { - Util.invoke(com.sun.tools.doclets.standard.ExecutableMemberSubWriter.class, - mw, - "printParameters", - new Class[]{ExecutableMemberDoc.class}, - new Object[]{member}); - } - public static void printUseInfo(AbstractSubWriter mw, - Object mems, - String heading) { - printUseInfo(mw.del(), mems, heading); - } - public static void printUseInfo - (com.sun.tools.doclets.standard.AbstractSubWriter mw, - Object mems, - String heading) { - if (mw != null) { - Util.invoke(com.sun.tools.doclets.standard.AbstractSubWriter.class, - mw, - "printUseInfo", - new Class[]{Object.class, String.class}, - new Object[]{mems, heading}); - } - } - public static void printCommentDef(AbstractSubWriter mw, Doc doc) { - Util.invoke(SubWriterHolderWriter.class, - writer(mw), - "printCommentDef", - new Class[]{Doc.class}, - new Object[]{doc}); - } - public static SubWriterHolderWriter writer(AbstractSubWriter mw) { - return (SubWriterHolderWriter) - Util.access(com.sun.tools.doclets.standard.AbstractSubWriter.class, - mw, "writer"); - } - public static SortedSet pkgSet(ClassUseWriter writer) { - return (SortedSet)Util.access(ClassUseWriter.class, - writer, - "pkgSet"); - } - public static ClassDoc classdoc(ClassUseWriter writer) { - return (ClassDoc)Util.access(ClassUseWriter.class, - writer, - "classdoc"); - } - public static void print(com.sun.tools.doclets.standard.AbstractSubWriter mw, - String str) { - Util.invoke(com.sun.tools.doclets.standard.AbstractSubWriter.class, - mw, - "print", - new Class[]{String.class}, - new Object[]{str}); - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/AccessChecker.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/AccessChecker.java deleted file mode 100644 index fff631840..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/AccessChecker.java +++ /dev/null @@ -1,178 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.ajdoc; - -import org.aspectj.compiler.base.ast.Modifiers; -import org.aspectj.compiler.base.ast.FieldDec; -import org.aspectj.compiler.base.ast.TypeDec; -import org.aspectj.compiler.base.ast.NameType; -import org.aspectj.compiler.base.ast.CodeDec; -import org.aspectj.compiler.crosscuts.ast.PointcutDec; - -/** - * This utility tells whether a declaration is accessible - * based on its access modifiers (and that of its declaring - * class, if it is a member (i.e., including inner classes). - *

Instantiation and subclassing: - * The constants should suffice for most uses, but subclassing - * is permitted if you need to implement new functionality or - * make new instances. - */ -public abstract class AccessChecker { - // constants open doCanAccess to public to permit direct use - - /** return true only for public elements */ - public static final AccessChecker PUBLIC = new AccessChecker("public") { - public boolean doCanAccess(Modifiers mods, Object object) { - return mods.isPublic(); - } - }; - - /** return true for public and protected elements */ - public static final AccessChecker PROTECTED = new AccessChecker("protected") { - public boolean doCanAccess(Modifiers mods, Object object) { - return mods.isPublic() || mods.isProtected(); - } - }; - - /** return true unless private elements */ - public static final AccessChecker PACKAGE = new AccessChecker("package") { - public boolean doCanAccess(Modifiers mods, Object object) { - return !mods.isPrivate(); - } - }; - - /** return true for all elements */ - public static final AccessChecker PRIVATE = new AccessChecker("private") { - public boolean doCanAccess(Modifiers mods, Object object) { - return true; - } - }; - - /** lowercase option without - */ - protected final String optionName; - - /** - * Encourage use of static constants by prohibiting construction - * but permit new subclasses. - * Subclasses should ensure optionName is lowercase and - * doCanAccess is public if need be. - */ - protected AccessChecker(String optionName){ - this.optionName = optionName; - } - - /** @return true if modifiers permitted for self and declaring type */ - public boolean canAccess(FieldDec dec) { - if (null == dec) return false; - if (!canAccess(dec.getModifiers(), dec)) { - return false; - } else { - return canAccess(dec.getBytecodeTypeDec()); - } - } - - /** @return true if modifiers permitted for self and declaring type */ - public boolean canAccess(CodeDec dec) { - if (null == dec) return false; - if (!canAccess(dec.getModifiers(), dec)) { - return false; - } else { - return canAccess(dec.getBytecodeTypeDec()); - } - } - - /** @return true if modifiers permitted for self and declaring type */ - public boolean canAccess(PointcutDec dec) { - if (null == dec) return false; - if (!canAccess(dec.getModifiers(), dec)) { - return false; - } else { - return canAccess(dec.getBytecodeTypeDec()); - } - } - - /** decode dec modifiers and return whether access is permitted - * Access is permitted if it is permitted to the dec. - * The caller must prohibit access when displaying in the aspect - * (i.e., canAccess(dec.getLexicalType()) or in - * the target class - * (i.e., canAccess(dec.getDeclaringType())) - * and to the enclosing lexical type (i.e,. the enclosing aspect). - */ - /* - public boolean canAccess(IntroducedDec dec) { // todo: users - if (null == dec) return false; - if (!canAccess(dec.getModifiers(), dec)) { - return false; - } else { - return canAccess(dec.getLexicalType()); - } - } - */ - - /** @return true if modifiers permitted for self and any enclosing type */ - public boolean canAccess(TypeDec dec) { - if (null == dec) return false; - boolean result = canAccess(dec.getModifiers(), dec); - if (result) { - // avoiding NPE in getEnclosingInstanceTypeDec - NameType outerType = dec.getEnclosingInstanceType(); - TypeDec outer = (null == outerType? null - : outerType.getTypeDec()); // todo: typeDec? - result = ((null == outer) || canAccess(outer)); - } - return result; - } - - /** - * This is called from canAccess to log any results - * of doCanAccess - * and should return the result or a principled variant thereof. - */ - protected boolean canAccessLog(Modifiers mods, Object object, - boolean result) { - return result; - } - - /** - * Check whether client has access to the object - * based on the modifiers. - * @param object the Object with the modifier flags - may be null - * @param modifiers the Modifiers to check - * @return false if modifiers are null or true if access is permitted - */ - // todo: object unused but useful for logging - public final boolean canAccess(Modifiers mods, Object object) { - boolean result = (null == mods? false : doCanAccess(mods, object)); - return canAccessLog(mods, object, result); - } - - /** @return lowercase variant of option name (e.g., "private" for -private) */ - public final String getOption() { return optionName; } - - /** @return UPPERCASE variant of option name (e.g., "PRIVATE" for -private) */ - public final String toString() { return optionName.toUpperCase(); } - - /** subclasses implement semantics here. */ - abstract protected boolean doCanAccess(Modifiers mods, Object object); -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/AdviceDocImpl.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/AdviceDocImpl.java deleted file mode 100644 index 7b10288b0..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/AdviceDocImpl.java +++ /dev/null @@ -1,199 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.ajdoc; - - -import org.aspectj.ajdoc.AdviceDoc; -import org.aspectj.ajdoc.AspectDoc; -import org.aspectj.ajdoc.ClassDoc; -import org.aspectj.ajdoc.ExecutableMemberDoc; -import org.aspectj.compiler.base.ast.CodeDec; -import org.aspectj.compiler.base.ast.FormalDec; -import org.aspectj.compiler.base.ast.NameType; -import org.aspectj.compiler.base.ast.TypeDec; -import org.aspectj.compiler.crosscuts.ast.AdviceDec; -import org.aspectj.compiler.crosscuts.ast.AfterReturningAdviceDec; -import org.aspectj.compiler.crosscuts.ast.AfterThrowingAdviceDec; -import org.aspectj.compiler.crosscuts.ast.AroundAdviceDec; - -import com.sun.javadoc.Type; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -public class AdviceDocImpl extends CodeDocImpl implements AdviceDoc { - - /** Crosscuts this advice affects. */ - private final Collection crosscuts; - - /** - * Constructrs an AdviceDoc with the containing ClassDoc - * and underlying AdviceDec. - * - * @param containingClass containing ClassDoc. - * @param adviceDec underlying AdviceDec. - */ - public AdviceDocImpl(ClassDoc containingClass, AdviceDec adviceDec) { - super(containingClass, adviceDec); - crosscuts = createCrosscuts(); - } - - /** - * Returns the underlying Dec -- an AdviceDec. - * - * @return the underlying Dec -- an AdviceDec. - */ - protected AdviceDec adviceDec() { - return (AdviceDec)codeDec(); - } - - /** - * Return the ExecutableMemberDocs this advice crosscuts. - * - * @return an array of ExecutableMemberDocs representing - * the members this advice crosscuts. - */ - public com.sun.javadoc.ExecutableMemberDoc[] crosscuts() { - return (ExecutableMemberDoc[])crosscuts.toArray - (new ExecutableMemberDoc[crosscuts.size()]); - } - - /** - * Returns null, because advice can't override - * other advice. - * - * @return null, because advice can't override - * other advice. - */ - public AspectDoc overriddenAspect() { - return null; - } - - /** - * Returns the return type of the advice -- it may be null. - * - * @return the return type of the advice -- it may be null. - */ - public com.sun.javadoc.Type returnType() { - if (adviceDec() instanceof AroundAdviceDec) { - return TypeImpl.getInstance(adviceDec().getReturnType()); - } else { - return null; - } - } - - /** - * Returns true. - * - * @return true. - */ - public boolean isAdvice() { - return true; - } - - /** - * Returns true if this advice is abstract. - * - * @return true if this advice is abstract. - */ - public boolean isAbstract() { - return adviceDec().isAbstract(); - } - - - /** - * Returns true if this is throwing advice. - * - * @return true if this is throwing advice. - */ - public boolean isThrowing() { - return adviceDec() instanceof AfterThrowingAdviceDec; - } - - /** - * Returns true if this is returning advice. - * - * @return true if this is returning advice. - */ - public boolean isReturning() { - return adviceDec() instanceof AfterReturningAdviceDec; - } - - /** - * Returns the extra formal type that's the optional type - * to after returning or after throwing - * advice. - * - * @return an instance of Type that represents the the extra formal type - * that's the optional type to after returning or - * after throwing advice. - */ - public Type extraType() { - FormalDec fd = adviceDec().getExtraFormal(); - if (fd != null) { - return TypeImpl.getInstance(fd.getType()); - } - return null; - } - - - /** - * Returns a Collection of CodeDocImpl representing the - * crosscuts the underlying TypeDec declares. - * - * @return a Collection of CodeDocImpl representing the - * crosscuts the underlying TypeDec declares. - */ - private Collection createCrosscuts() { - Set affects = ajc().getCorrespondences().getAffects(adviceDec()); - if (affects.size() < 1) return Collections.EMPTY_LIST; - List list = new ArrayList(); - for (Iterator i = affects.iterator(); i.hasNext();) { - Object o = i.next(); - if (o instanceof CodeDec) { - CodeDec cdec = (CodeDec)o; - TypeDec owner = ((NameType)cdec.getDeclaringType()).getTypeDec(); - ClassDocImpl cd = ClassDocImpl.getInstance(owner); - CodeDocImpl cdoc = cd.docForDec(cdec); - if (cdoc != null) { // todo: silent introduced members - list.add(cdoc); - } - } - } - return list; - } - - /** - * Returns the simple name of this advice. Need to override - * this so we don't print afterThrowing or afterReturning. - * - * @return one of after, before, around. - */ - public String name() { - if (isThrowing() || isReturning()) return "after"; - return super.name(); - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/Ajdoc.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/Ajdoc.java deleted file mode 100644 index 59dec5283..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/Ajdoc.java +++ /dev/null @@ -1,384 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.ajdoc; - -import org.aspectj.compiler.base.CompilerErrors; -import org.aspectj.compiler.base.ExitRequestException; -import org.aspectj.compiler.base.InternalCompilerError; - -import com.sun.javadoc.RootDoc; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.List; - -/** - * Front-end for ajdoc. - * - */ -public class Ajdoc extends AjdocCompiler { - - private final static int VERBOSE = 1; - private final static int WARNINGS = 4; - - private DocletProxy docletProxy; - private RootDocMaker rootDocMaker; - private String source = null; - private String extdirs = null; - private String locale = null; - private String encoding = null; - private String sourcepath = null; - private String classpath = null; - private String bootclasspath = null; - private int verbosity = WARNINGS; - private List filenamesAndPackages = new ArrayList(); - private List options = new ArrayList(); - - public Ajdoc(String programName) { - super(programName); - } - - public Ajdoc() { - this("ajdoc"); - } - - /** - * Programmatic entry into this compiler that - * uses the error printer to catch internal errors. - * - * @param args Command line arguments. - * @return 0 for a successful document. - */ - public int execute(String[] args) { - try { - return doc(args) && err.getNumErrors() == 0 ? 0 : 1; - } catch (ExitRequestException exit) { - return exit.getValue(); - } catch (CompilerErrors err) { - return err.errors; // report error already printed by ajc - } catch (InternalCompilerError error) { // cf ajc.Main - handleInternalError(error.uncaughtThrowable); - error.showWhere(new PrintWriter(System.err)); - return -2; - } catch (Exception e) { - e.printStackTrace(System.err); - err.internalError("internal_msg", e); - return 1; - } - } - - /** copied from ajc.Main */ - public void handleInternalError(Throwable uncaughtThrowable) { - System.err.println("An internal error occured in Ajdoc invocation of AspectJ-" - +getCompiler().getVersion()); - System.err.println(uncaughtThrowable.toString()); - uncaughtThrowable.printStackTrace(System.err); - System.err.println(); - } - - /** - * Programmatic entry into this compiler that - * doesn't use the error printer to catch internal errors. - * - * @param args Command line arguments. - * @return true for a succesful run. - */ - public boolean doc(String[] args) { - - long start = System.currentTimeMillis(); - - if (args == null) { - err.error("internal_error", "Arguments cannot be null"); - return false; - } - - try { - args = expandAndCreateDoclet(args); - } catch (FileNotFoundException e) { - err.error("file_not_found_exception", e.getMessage()); - return false; - } catch (IOException e) { - err.error("io_exception", e.getMessage()); - return false; - } - - for (int i = 0; i < args.length;) { - String arg = args[i++]; - if (arg.equals("-overview")) { - set(args, i++); - } else if (arg.equals("-public")) { - set(arg); - if (filter != null) { - err.error("argument_already_seen", arg); - } else { - setFilter(AccessChecker.PUBLIC, arg); - } - } else if (arg.equals("-protected")) { - set(arg); - if (filter != null) { - err.error("argument_already_seen", arg); - } else { - setFilter(AccessChecker.PROTECTED, arg); - } - } else if (arg.equals("-package")) { - set(arg); - if (filter != null) { - err.error("argument_already_seen", arg); - } else { - setFilter(AccessChecker.PACKAGE, arg); - } - } else if (arg.equals("-private")) { - set(arg); - if (filter != null) { - err.error("argument_already_seen", arg); - } else { - setFilter(AccessChecker.PRIVATE, arg); - } - } else if (arg.equals("-help")) { - usage(0); - } else if (arg.equals("-sourcepath")) { - if (sourcepath != null) { - usage("argument_already_seen", arg); - } - sourcepath = set(args, i++); - }else if (arg.equals("-classpath")) { - if (classpath != null) { - usage("argument_already_seen", arg); - } - classpath = set(args, i++); - }else if (arg.equals("-bootclasspath")) { - if (bootclasspath != null) { - usage("argument_already_seen", arg); - } - bootclasspath = set(args, i++); - }else if (arg.equals("-source")) { - if (source != null) { - usage("argument_already_seen", arg); - } - source = set(args, i++); - } else if (arg.equals("-extdirs")) { - if (extdirs != null) { - usage("argument_already_seen", arg); - } - extdirs = set(args, i++); - } else if (arg.equals("-verbose")) { - set(arg); - verbosity |= VERBOSE; - } else if (arg.equals("-locale")) { - if (locale != null) { - usage("argument_already_seen", arg); - } - set(args, i++); - } else if (arg.equals("-encoding")) { - if (encoding != null) { - usage("argument_already_seen", arg); - } - encoding = set(args, i++); - } else if (arg.equals("-compiler")) { - err.warning("usage_help", "-compiler option ignored"); - } else if (arg.equals("-debug")) { - err.warning("usage_help", "-debug option disabled"); - } else if (arg.startsWith("-J")) { // todo unsupported? - if (arg.length() == 2) continue; - String rest = arg.substring(2); - int ieq = rest.indexOf('='); - String key, val; - if (ieq != -1) { - key = rest.substring(0, ieq); - val = rest.substring(ieq+1); - } else { - key = rest; - val = ""; - } - System.setProperty(key, val); - } else if (arg.startsWith("-")) { - int optionLength = docletProxy.optionLength(arg); - if (optionLength < 0) { - exit(); - } else if (optionLength == 0) { - usage("invalid_flag", arg); - } else if (optionLength > args.length) { - usage("requires_argument", arg, optionLength+""); - } else { - List iargs = new ArrayList(); - iargs.add(arg); - for (int j = 0; j < optionLength-1; j++) { - iargs.add(args[i++]); - } - set((String[])iargs.toArray(new String[iargs.size()])); - } - } else { - filenamesAndPackages.add(arg); - } - } - if (locale == null) { - locale = ""; - } - if (sourcepath == null) { - sourcepath = "."; - } - try { - if (!docletProxy.validOptions(options, err)) { - exit(1); - } - } catch (IOException e) { - e.printStackTrace(System.err); - err.internalError("internal_msg", e); - return false; - } - if (filenamesAndPackages.size() < 1) { - usage("No_packages_or_classes_specified"); - return false; - } - RootDoc rootDoc = null; - boolean good = true; - try { - rootDoc = makeRootDoc(sourcepath, - classpath, - bootclasspath, - extdirs, - verbosity, - encoding, - locale, - source, - filenamesAndPackages, - options, - err, - programName, - getFilter()); - } catch (CannotMakeRootDocException e) { - err.error("cant_create_root_doc_ex", "AjdocCompiler", e.getMessage()); - exit(1); - good = false; - } - good &= rootDoc != null; - if (good) { - err.notice("generating_docs"); - try { - good &= docletProxy.start(rootDoc); - } catch (IOException e) { - e.printStackTrace(System.err); - err.internalError("internal_msg", e); - return false; - } - } - if ((verbosity & VERBOSE) != 0) { - err.notice("done_in", Long.toString(System.currentTimeMillis()-start)); - } - return good; - } - - - private void usage(String key, String s0, String s1) { - err.error(key, s0, s1); - usage(1); - } - - private void usage(String key, String s0) { - usage(key,s0,""); - } - - private void usage(String key) { - usage(key,""); - } - - private void usage() { - err.notice("usage_help", programName); - if (docletProxy != null) { docletProxy.optionLength("-help"); } - } - - private void usage(int exit) { - usage(); - exit(exit); - } - - protected String[] expandAndCreateDoclet(String[] args) throws IOException { - List list = new ArrayList(); - docletProxy = DocletProxy.DEFAULT; - for (int i = 0; i < args.length;) { - String arg = args[i++]; - if (arg == null || arg.length() < 1) continue; - if (arg.charAt(0) == '@') { - expandAtFile(arg.substring(1), list); - } else if (arg.equals("-argfile")) { - if (check(args, i)) { - expandAtFile(args[i++], list); - } - } else if (arg.equals("-doclet")) { - err.warning("usage_help", "-doclet option ignored"); - } else if (arg.equals("-docletpath")) { - err.warning("usage_help", "-docletpath option ignored"); - } else if (arg.equals("-standard")) { - docletProxy = DocletProxy.STANDARD; - } else { - list.add(arg); - } - } - return (String[])list.toArray(new String[list.size()]); - } - - private static boolean check(String[] args, int i) { - return i >= 0 && i < args.length; - } - - private String set(String[] args, int i) { - String arg = null; - if (check(args, i)) { - arg = args[i]; - set(args[i-1], arg); - } else { - err.internalError("internal_error", - new ArrayIndexOutOfBoundsException(i)); - } - return arg; - } - - private void set(String opt) { - set(new String[]{opt}); - } - - private void set(String opt, String arg) { - set(new String[]{opt, arg}); - } - - private void set(String[] opts) { - options.add(opts); - } - - protected void internalCompile(List filenames) { - super.internalCompile(filenames); - } - - private final void exit() { - exit(0); - } - - private void exit(int exit) { - throw new ExitRequestException(exit); - } - - private static String classname(Object o) { - return o != null ? o.getClass().getName() : "null"; - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/AjdocCompiler.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/AjdocCompiler.java deleted file mode 100644 index b374587cf..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/AjdocCompiler.java +++ /dev/null @@ -1,605 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.ajdoc; - -import org.aspectj.compiler.base.AbstractCompilerPass; -import org.aspectj.compiler.base.ErrorHandler; -import org.aspectj.compiler.base.ast.CompilationUnit; -import org.aspectj.compiler.base.ast.Dec; -import org.aspectj.compiler.base.ast.Decs; -import org.aspectj.compiler.base.ast.TypeDec; -import org.aspectj.compiler.base.ast.World; -import org.aspectj.compiler.crosscuts.AspectJCompiler; - -import com.sun.javadoc.DocErrorReporter; -import com.sun.javadoc.RootDoc; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileFilter; -import java.io.FileReader; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.StringTokenizer; - -/** - * Extension of the AspectJCompiler to provide - * functionality for creating documentation. - * - * @author Jeff Palm - */ -public class AjdocCompiler extends AspectJCompiler implements RootDocMaker { - - /** The name of the program. */ - protected final String programName; - - /** The error printer we use. */ - protected final ErrPrinter err; - - /** - * Construct a new ajdoc compile with the - * error handler errorHandler and - * name programName - * - * @param errorHandler the error handler. - * @param programName the name of the program. - */ - public AjdocCompiler(ErrorHandler errorHandler, String programName) { - super(errorHandler); - getOptions().preprocess = true; - getOptions().nocomments = true; - (errorHandler = err = - new ErrPrinter(this.programName = programName)). - setCompiler(this); - } - - /** - * Construct a new ajdoc compile with the - * name programName. - * - * @param programName the name of the program. - */ - public AjdocCompiler(String programName) { - this(null, programName); - } - - /** - * Returns the ErrPrinter currently used. - * - * @return the ErrPrinter currently used. - */ - public ErrPrinter err() { - return err; - } - - /** The packages found on the command line. */ - private Set pkgnames = new HashSet(); - - /** The classes found on the command line and from files. */ - private Set classnames = new HashSet(); - - /** The source files on the command line. */ - private Set files = new HashSet(); - - /** The list of source files to compile. */ - protected final List srcfiles = new ArrayList(); - - /** The list of filenames that came from user-specified source files. */ - protected List srcSrcfilenames = new ArrayList(); - - /** The list of filenames that came from user-specified packages. */ - protected List pkgSrcfilenames = new ArrayList(); - - /** The list of filenames that came from user-specified classes. */ - protected List clsSrcfilenames = new ArrayList(); - - /** The source path with which to search. */ - protected final List sourcepaths = new ArrayList(); - { - sourcepaths.add(new File(".")); - } - /** The list of filenames that came from user-specified classes. */ - protected AccessChecker filter; - - /** - * Create the RootDoc. - */ - public RootDoc makeRootDoc(String sourcepath, - String classpath, - String bootclasspath, - String extdirs, - long flags, - String encoding, - String locale, - String source, - List filenamesAndPackages, - List options, - DocErrorReporter err, - String programName, - AccessChecker filter) - throws CannotMakeRootDocException { - if ((null != filter) && (this.filter != filter)) { - this.filter = filter; - } - if (null == this.filter) { - this.filter = AccessChecker.PROTECTED; - } - if (classpath != null) { - getOptions().classpath = classpath; - } - if (bootclasspath != null) { - getOptions().bootclasspath = bootclasspath; - } - if (extdirs != null) { - getOptions().extdirs = extdirs; - } - if (source != null) { - getOptions().source = source; - } - resolveSourcePath(sourcepath); - resolveFilesAndPackages(filenamesAndPackages); - - Collections.sort(pkgSrcfilenames); - Collections.sort(clsSrcfilenames); - Collections.sort(srcSrcfilenames); - - srcfiles.addAll(pkgSrcfilenames); - srcfiles.addAll(clsSrcfilenames); - srcfiles.addAll(srcSrcfilenames); - - err().notice("starting_internal_compile"); - - for (Iterator i = options.iterator(); i.hasNext();) { - String[] opts = (String[])i.next(); - if (opts.length == 1) { - if (opts[0].equals("-verbose")) { - getOptions().verbose = true; - } - } else if (opts.length == 2) { - if (opts[0].equals("-classpath")) { - getOptions().classpath = opts[1]; - } else if (opts[1].equals("-bootclasspath")) { - getOptions().bootclasspath = opts[1]; - } else if (opts[1].equals("-extdirs")) { - getOptions().extdirs = opts[1]; - } - } - } - - // Compile the srcfiles - have to add passes first - addPasses(); - internalCompile(srcfiles); - - // This is the world with which we create the root - World world = getWorld(); - - // Add all the classes found in the source files - // to the list of specified classnames - for (Iterator i = world.getCompilationUnits().iterator(); - i.hasNext();) { - Decs decs = ((CompilationUnit)i.next()).getDecs(); - for (int j = 0, N = decs.size(); j < N; j++) { - Dec dec = decs.get(j); - if (dec instanceof TypeDec) { - classnames.add(((TypeDec)dec).getFullName()); - } - } - } - - // Initialize and return the root created - // from the our world - err().notice("creating_root"); - RootDoc result = init(this, (String[][])options.toArray - (new String[options.size()][])); - - // do another pass at RootDoc after constructed - com.sun.javadoc.ClassDoc[] cds = result.classes(); - for (int i = 0; i < cds.length; i++) { - if (cds[i] instanceof ClassDocImpl) { - ClassDocImpl cd = (ClassDocImpl) cds[i]; - cd.postProcess(); - } - } - return result; - } - - - private static AjdocCompiler instance; - { instance = this; } - - public static AjdocCompiler instance() { - return instance; - } - - /** - * The entry point to initialize a world created - * from an AspectJCompiler. - * - * @param ajc the compiler. - * @param options the ajdoc options. - * @return a RootDocImpl representing the - * documentation tree. - */ - public static RootDocImpl init(AspectJCompiler ajc, String[][] options) { - - if (ajc == null) return null; //TODO: make empty - - World world = ajc.getWorld(); - - Collection classnames = null; - Collection pkgnames = null; - if (ajc instanceof AjdocCompiler) { - AjdocCompiler ajdoc = (AjdocCompiler)ajc; - pkgnames = ajdoc.pkgnames; - classnames = ajdoc.classnames; - } - - PackageDocImpl.init(ajc); - - AccessChecker filter = AccessChecker.PUBLIC; - if (ajc instanceof AjdocCompiler) { - filter = ((AjdocCompiler) ajc).getFilter(); - } - RootDocImpl root = new RootDocImpl(world, - options, - pkgnames, - classnames, - filter); - return root; - } - - /** set filter associated with this compiler */ - protected void setFilter(AccessChecker filter, String arg) { - this.filter = filter; - } - - /** get filter associated with this compiler */ - public final AccessChecker getFilter() { - return filter; - } - - protected final void expandAtFile(String filename, - List args) throws IOException { - BufferedReader in = new BufferedReader(new FileReader(filename)); - String dirfile = new File(filename).getParent(); - File basedir = new File(null == dirfile ? "." : dirfile ) ; - String line; - while ((line = in.readLine()) != null) { - if (line == null || line.length() < 1) continue; - line = line.trim(); - if (line.startsWith("//")) continue; - if (line.startsWith("#")) continue; - if (line.startsWith("@")) { - line = line.substring(1); - File newfile = new File(line); - newfile = newfile.isAbsolute() ? - newfile : new File(basedir, line); - expandAtFile(newfile.getPath(), args); - } else { - File newfile = new File(line); - newfile = newfile.isAbsolute() ? - newfile : new File(basedir, line); - if (newfile.exists()) { - boolean result = maybeAdd(newfile, args); - if (!result) { - // we only support valid filenames, not options - cantResolve(newfile); - } - } else { - boolean addedFile = false; - FileFilter filter = null; - String name = newfile.getName().trim(); - if (name.equals("*.java")) { - filter = new FileFilter() { - public boolean accept(File f) { - return f != null && - f.getName().endsWith(".java"); - } - }; - } else if (name.equals("*.aj")) { - filter = new FileFilter() { - public boolean accept(File f) { - return f != null && - f.getName().endsWith(".java"); - } - }; - } else if (name.equals("*")) { - filter = new FileFilter() { - public boolean accept(File f) { - return f != null && - (f.getName().endsWith(".java") - || f.getName().endsWith(".aj")); - } - }; - } - if (null != filter) { - File parentDir = newfile.getParentFile(); - File[] javafiles = parentDir.listFiles(filter); - if (javafiles != null) { - for (int i = 0; i < javafiles.length; i++) { - if (maybeAdd(javafiles[i], args)) { - if (!addedFile) addedFile = true; - } else { - cantResolve(javafiles[i]); - } - } - } - } - if (!addedFile) { - if (isValidPkg(line)) { - args.add(line); - } else { - cantResolve(newfile); - } - } - } - } - } - in.close(); - } - - protected final void cantResolve(File f) { - err().error("cant_resolve_file", f.getAbsolutePath()); - } - - private void resolveSourcePath(String sourcepath) { - if (sourcepath != null) { - sourcepaths.remove(0); - for (StringTokenizer t = new StringTokenizer(sourcepath, - File.pathSeparator); - t.hasMoreTokens();) { - File path = new File(t.nextToken().trim()); - if (path.exists() && path.isDirectory()) { - sourcepaths.add(path); - } - } - // TODO: don't want this, I think ???? - //sourcepaths.add(new File(".")); - } - } - - private void resolveFilesAndPackages(List filenamesAndPackages) { - Collection pkgnamesFromCmd = new HashSet(); - for (Iterator i = filenamesAndPackages.iterator(); i.hasNext();) { - String str = (String)i.next(); - File file = new File(str); - if (/*file.isAbsolute() &&*/ maybeAdd(file, srcSrcfilenames)) { - addFile(file); - continue; - } else { - for (Iterator j = sourcepaths.iterator(); j.hasNext();) { - File sourcepath = (File)j.next(); - file = new File(sourcepath, str); - if (maybeAdd(file, srcSrcfilenames)) { - addFile(file); - continue; - } - } - } - pkgnamesFromCmd.add(str); - } - for (Iterator i = pkgnamesFromCmd.iterator(); i.hasNext();) { - resolvePackageOrClass((String)i.next()); - } - } - - private void resolvePackageOrClass(String pkgOrClassName) { - boolean recurse; - String pkgOrClass = - (recurse = (pkgOrClassName.endsWith(".*"))) ? - pkgOrClassName.substring(0, pkgOrClassName.length()-2) : - pkgOrClassName; - for (Iterator i = sourcepaths.iterator(); i.hasNext();) { - File sourcepath = (File)i.next(); - File possiblePkg = new File(sourcepath, - pkgOrClass.replace - ('.', File.separatorChar)); - if (possiblePkg.exists() && possiblePkg.isDirectory()) { - if (recurse) { - File[] dirs = possiblePkg.listFiles - (new FileFilter() { - public boolean accept(File f) { - return f != null && f.isDirectory(); - } - }); - for (int j = 0; j < dirs.length; j++) { - String pkgname = pkgOrClass + '.' + dirs[j].getName(); - resolvePackageOrClass(pkgname + ".*"); - } - } - File[] javafiles = possiblePkg.listFiles - (new FileFilter() { - public boolean accept(File f) { - return f != null && !f.isDirectory(); - } - }); - if (javafiles.length > 0) { - pkgnames.add(pkgOrClass); - } - boolean addedPkg = false; - for (int j = 0; j < javafiles.length; j++) { - if (maybeAdd(javafiles[j], pkgSrcfilenames) && !addedPkg) { - addPkg(pkgOrClass, javafiles[j]); - addedPkg = true; - } - } - break; - } else { - String pkgname = ""; - String classname = pkgOrClass; - int ilastdot = pkgOrClass.lastIndexOf('.'); - if (ilastdot != -1) { - pkgname = pkgOrClass.substring(0, ilastdot). - replace('.', File.separatorChar) + File.separatorChar; - classname = pkgOrClass.substring(ilastdot+1); - } - File file = new File(sourcepath, - pkgname + classname + ".java"); - if (maybeAdd(file, clsSrcfilenames)) { - addClass(pkgOrClass, file); - break; - } - } - } - } - - protected final File findFile(String filename, boolean isDir) { - for (Iterator i = sourcepaths.iterator(); i.hasNext();) { - File sourcepath = (File)i.next(); - File file = new File(sourcepath, filename); - if (file.exists() && !(isDir ^ file.isDirectory())) { - return file; - } - } - return null; - } - - protected static boolean maybeAddPkg(String pkgname, - Collection pkgnames) { - if (isValidPkg(pkgname)) { - pkgnames.add(pkgname); - return true; - } - return false; - } - - protected final Map filesToClassnames = new HashMap(); - protected final void addClass(String classname, File file) { - if (!(maybeAddClass(classname))) { - err().error("invalid_class_name", classname); - } else { - filesToClassnames.put(file.getAbsoluteFile(), classname); - } - } - - protected final boolean maybeAddClass(String classname) { - return maybeAddClass(classname, classnames); - } - - protected static boolean maybeAddClass(String classname, - Collection classnames) { - if (isValidClass(classname)) { - classnames.add(classname); - return true; - } - return false; - } - - protected final static boolean isValidClass(String classname) { - return isValidPkg(classname); - } - - protected final Map filesToPkgnames = new HashMap(); - protected final void addPkg(String pkgname, File file) { - if (!maybeAddPkg(pkgname)) { - err().error("invalid_package_name", pkgname); - } else { - filesToPkgnames.put(file.getAbsoluteFile(), pkgname); - } - } - - protected final boolean maybeAddPkg(String pkgname) { - return maybeAddPkg(pkgname, pkgnames); - } - - protected final Map filesToFilenames = new HashMap(); - protected final void addFile(File file) { - files.add(file); - filesToFilenames.put(file.getAbsoluteFile(), file.getAbsolutePath()); - } - - protected static boolean maybeAdd(File file, Collection files) { - if (isValidJavaFile(file)) { - files.add(file.getAbsolutePath()); - return true; - } - return false; - } - - protected final static boolean isValidJavaFile(File file) { - return file != null && file.exists() && !file.isDirectory() - && (file.getName().endsWith(".java") - || file.getName().endsWith(".aj")) ; - } - - protected final static boolean isValidPkg(String pkgname) { - if (pkgname == null) { - return false; - } - if (pkgname.length() < 1) { - return true; - } - if (!Character.isJavaIdentifierStart(pkgname.charAt(0))) { - return false; - } - for (int i = 1; i < pkgname.length(); i++) { - char c = pkgname.charAt(i); - if (c == '.' && i == pkgname.length()-1) { - return false; - } - if (!(c == '.' || Character.isJavaIdentifierPart(c))) { - return false; - } - } - return true; - } - - protected void loading(CompilationUnit cu) { - File srcfile = cu.getSourceFile().getAbsoluteFile(); - String pkgname, classname, filename; - if ((pkgname = (String)filesToPkgnames.get(srcfile))!= null) { - AjdocCompiler.this.err().notice - ("Loading_source_files_for_package", pkgname); - } else if ((classname = (String)filesToClassnames.get(srcfile)) != null) { - AjdocCompiler.this.err().notice - ("Loading_source_file_for_class", classname); - } else if ((filename = (String)filesToFilenames.get(srcfile)) != null) { - AjdocCompiler.this.err().notice - ("Loading_source_file", filename); - } - } - - protected AbstractCompilerPass createParserPass() { - return new PrintingParserPass(this); - } - - protected static class PrintingParserPass extends AspectJCompiler.ParserPass { - public PrintingParserPass(AjdocCompiler jc) { super(jc); } - public void transform(CompilationUnit cu) { - ((AjdocCompiler)getCompiler()).loading(cu); - super.transform(cu); - } - } - - protected void addPasses() { - passes = new ArrayList(); - addPreSymbolPasses(); - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/AspectDocImpl.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/AspectDocImpl.java deleted file mode 100644 index f603476a1..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/AspectDocImpl.java +++ /dev/null @@ -1,300 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.ajdoc; - -import org.aspectj.ajdoc.AdviceDoc; -import org.aspectj.ajdoc.AspectDoc; -import org.aspectj.ajdoc.IntroductionDoc; -import org.aspectj.ajdoc.OfClauseDoc; -import org.aspectj.compiler.base.ast.Decs; -import org.aspectj.compiler.crosscuts.ast.AdviceDec; -import org.aspectj.compiler.crosscuts.ast.AspectDec; -import org.aspectj.compiler.crosscuts.ast.IntroducedSuperDec; - -import com.sun.javadoc.ClassDoc; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; - -public class AspectDocImpl extends ClassDocImpl implements AspectDoc { - - /** Array of AdviceDoc created from this AspectDecs AdviceDecs. */ - private final Collection advice; - - /** Array of IntroductionDec created from this AspectDecs introductions. */ - private final Collection introductions; - - /** The of clause this aspect has -- may be null. */ - private final OfClauseDoc ofClause; - - /** The aspects that dominate this aspect. */ - private final Collection dominators = new ArrayList(); - - /** The aspects that are dominated by this aspect. */ - private final Collection dominatees = new ArrayList(); - - /** - * Constructs an AspectDoc with the containing ClassDoc - * and underlying AspectDec. - * - * @param containingClass contained ClassDoc. - * @param aspectDec underlying AspectDec. - */ - public AspectDocImpl(ClassDoc containingClass, AspectDec aspectDec) { - super(containingClass, aspectDec); - introductions = createIntroductions(); - advice = createAdvice(); - ofClause = createOfClause(); - } - - /** - * Returns an instance of AdviceDocImpl corresponding to - * the AdviceDec passed in. - * - * @param dec the AdviceDec mapping to the desired - * AdviceDocImpl. - * @return an instance of AdviceDocImpl corresponding to - * the AdviceDec passed in. - */ - public AdviceDocImpl docForDec(AdviceDec dec) { - for (Iterator i = advice.iterator(); i.hasNext();) { - AdviceDocImpl ad = (AdviceDocImpl)i.next(); - if (ad.dec() == dec) return ad; - } - return null; - } - - /** - * Returns an instance of IntroducedSuperDocImpl corresponding to - * the IntroducedSuperDec passed in. - * - * @param dec the IntroducedSuperDec mapping to the - * desired IntroducedSuperDocImpl - * @return an instance of IntroducedSuperDocImpl - * corresponding to the IntroducedSuperDec - * passed in. - */ - public IntroducedSuperDocImpl introDocForDec(IntroducedSuperDec dec) { - for (Iterator i = introductions.iterator(); i.hasNext();) { - ProgramElementDocImpl id = (ProgramElementDocImpl)i.next(); - if (id.dec() == dec) return (IntroducedSuperDocImpl)id; - } - return null; - } - - /** - * Returns the underlying AspectDec. - * - * @return the underlying AspectDec. - */ - protected AspectDec aspectDec() { - return (AspectDec)typeDec(); - } - - /** - * Returns the visible advice in this aspect. - * - * @return an array of AdviceDoc representing the - * visible advice in this aspect. - */ - public AdviceDoc[] advice() { - return (AdviceDocImpl[])advice.toArray - (new AdviceDocImpl[advice.size()]); - } - - /** - * Returns the aspects that are dominated by this aspect. - * - * @return an array of AspectDec representing the aspects - * that are dominated by this aspect. - */ - public AspectDoc[] dominatees() { - return (AspectDoc[])dominatees.toArray - (new AspectDoc[dominatees.size()]); - } - - /** - * Return the aspects that dominate this aspect. - * - * @return an array of AspectDoc representing the aspects - * that dominate this aspect. - */ - public AspectDoc[] dominators() { - return (AspectDoc[])dominators.toArray - (new AspectDoc[dominators.size()]); - } - - /** - * TODO - * Returns the visible introductions of this aspect. - * - * @return an array of IntroductionDoc representing the - * visible introductions in this aspect. - */ - public IntroductionDoc[] introductions() { - return (IntroductionDocImpl[])introductions.toArray - (new IntroductionDocImpl[introductions.size()]); - } - - /** - * Returns the of clause of this aspect. - * - * @return the of clause of this aspect. - */ - public OfClauseDoc ofClause() { - return ofClause; - } - - /** - * Returns true. - * - * @return true. - */ - public boolean isAspect() { - return true; - } - - /** - * Returns true if this aspects dominates - * the passed in aspect. - * - * @param other an AspectDoc that represents another - * aspect in this world. - * @return true if this aspects dominates - * the passed in aspect. - */ - public boolean dominates(AspectDoc other) { - if (!(other instanceof AspectDocImpl)) { - return false; - } - return aspectDec().dominates(((AspectDocImpl)other).aspectDec()); - } - - /** - * Adds a dominates relation from dominator to - * this. For example, somewhere in the code - * the line - * - * aspect dominator dominates this { ... } - * - * exists. - * - * @param dominator an instance of AspectDocImpl that - * dominates this. - */ - public void addDominator(AspectDoc dominator) { - dominators.add(dominator); - } - - /** - * Adds a dominates relation from dominator to - * this. For example, somewhere in the code - * the line - * - * aspect this dominates dominatee { ... } - * - * exists. - * - * @param dominatee an instance of AspectDocImpl that - * is dominated by this. - */ - public void addDominatee(AspectDoc dominatee) { - dominatees.add(dominatee); - } - - /** - * Returns a Collection of IntroductionDocImpl representing - * the introductions declared in this aspect. - * - * @return a Collection of IntroductionDocImpl representing - * the introductions declared in this aspect. - */ - private Collection createIntroductions() { - Decs decs = aspectDec().getBody(); - if (decs.size() < 1) return Collections.EMPTY_LIST; - Collection list = new HashSet(); - for (Iterator i = decs.getList().iterator(); i.hasNext();) { - Object o = IntroductionDocImpl.getInstance(this, i.next()); - if (o != null) list.add(o); - } - return list; - } - - /** - * Returns a Collection of AdviceDocImpl representing - * the advice declared in this aspect. - * - * @return a Collection of AdviceDocImpl representing - * the advice declared in this aspect. - */ - private Collection createAdvice() { - // pluck the AdviceDec from the list of JpPlannerMakers - List decs = aspectDec().getJpPlannerMakers(); - if (null != decs) { - final int QUIT = 2; - for (int tries = 0; tries < QUIT; tries++) { - try { - for (Iterator i = decs.iterator(); i.hasNext();) { - Object o = i.next(); - if (!(o instanceof AdviceDec)) { - i.remove(); - } - } - tries = QUIT; - } catch (UnsupportedOperationException o) { - if (0 != tries) { - tries = QUIT; - } else { - ArrayList list = new ArrayList(); - list.addAll(decs); - decs = list; - } - } - } - } - - if ((null == decs) || (decs.size() < 1)) { - return Collections.EMPTY_LIST; - } - - List list = new ArrayList(); - for (Iterator i = decs.iterator(); i.hasNext();) { - list.add(new AdviceDocImpl(this, (AdviceDec)i.next())); - } - return list; - } - - /** - * Returns an instance of OfClauseDoc representing - * the of clause declared by this aspect. - * - * @return an instance of OfClauseDoc representing - * the of clause declared by this aspect. - */ - private OfClauseDoc createOfClause() { - return OfClauseDocImpl.getInstance(aspectDec().getPerClause()); - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/CannotMakeRootDocException.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/CannotMakeRootDocException.java deleted file mode 100644 index 646f5d35c..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/CannotMakeRootDocException.java +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.ajdoc; - -/** - * A simple wrapper exception to be thrown when we - * can't make a RootDoc. - * - * @see RootDocMaker#makeRootDoc - * @author Jeff Palm - */ -public class CannotMakeRootDocException extends RuntimeException { - - /** - * Constructs an empty exception. - */ - public CannotMakeRootDocException() { - super(); - } - - /** - * Constructs an exception with message message - * and a null contained Throwable - * - * @param message Message to use. - */ - public CannotMakeRootDocException(String message) { - this(message, null); - } - - /** - * Constructs an exception with message message - * an contained Throwable throwable. - * - * @param message Message to use. - * @param throwable Throwable to use. - */ - public CannotMakeRootDocException(String message, Throwable throwable) { - super((message != null ? message : "") + - (throwable != null ? ":" + throwable : "")); - } - - /** - * Constructs an exception with null message - * an contained Throwable throwable. - * - * @param throwable Throwable to use. - */ - public CannotMakeRootDocException(Throwable t) { - this(null, t); - } - -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/ClassDocImpl.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/ClassDocImpl.java deleted file mode 100644 index 7e8c21356..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/ClassDocImpl.java +++ /dev/null @@ -1,1107 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.ajdoc; - -import org.aspectj.ajdoc.IntroducedSuperDoc; -import org.aspectj.ajdoc.PointcutDoc; -import org.aspectj.compiler.base.ast.ClassDec; -import org.aspectj.compiler.base.ast.CodeDec; -import org.aspectj.compiler.base.ast.CompilationUnit; -import org.aspectj.compiler.base.ast.Constructor; -import org.aspectj.compiler.base.ast.ConstructorDec; -import org.aspectj.compiler.base.ast.Dec; -import org.aspectj.compiler.base.ast.Field; -import org.aspectj.compiler.base.ast.FieldDec; -import org.aspectj.compiler.base.ast.Import; -import org.aspectj.compiler.base.ast.Imports; -import org.aspectj.compiler.base.ast.InterfaceDec; -import org.aspectj.compiler.base.ast.Method; -import org.aspectj.compiler.base.ast.NameType; -import org.aspectj.compiler.base.ast.SourceLocation; -import org.aspectj.compiler.base.ast.TextSourceLocation; -import org.aspectj.compiler.base.ast.Type; -import org.aspectj.compiler.base.ast.TypeDec; -import org.aspectj.compiler.crosscuts.AspectJCompiler; -import org.aspectj.compiler.crosscuts.ast.AspectDec; -import org.aspectj.compiler.crosscuts.ast.IntroducedSuperDec; -import org.aspectj.compiler.crosscuts.ast.PointcutSO; - -import org.aspectj.ajdoc.ClassDoc; -import com.sun.javadoc.ConstructorDoc; -import com.sun.javadoc.FieldDoc; -import com.sun.javadoc.MethodDoc; -import com.sun.javadoc.PackageDoc; - -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * This implements ClassDoc and acts as a factory for ClassDocImpl - * and associated DocImpl. - * The factory will excluded new superclasses and introduction classes - * so the caller should take care to include those classes explicitly - * by adding them directly before they are sought indirectly or - * by post-processing them to enable inclusion as appropriate. - */ -public class ClassDocImpl - extends ProgramElementDocImpl - implements org.aspectj.ajdoc.ClassDoc { - - /** - * Returns an instance of ClassDoc represented by - * the passed in TypeDec. - * - * @param typeDec instance of TypeDec representing - * the ClassDoc that will be returned. - * @return an instance of ClassDoc mirroring - * the passed in TypeDec. - */ - public final static ClassDocImpl getInstance(TypeDec typeDec) { - return factory.getInstance(typeDec); - } - - /** - * Returns an instance of ClassDoc represented by - * the passed in TypeDec and containing ClassDoc (may be null). - * - * @param outerDoc the containing ClassDoc -- may be null. - * @param typeDec instance of TypeDec representing - * the ClassDoc that will be returned. - * @return an instance of ClassDoc mirroring - * the passed in TypeDec. - */ - public final static ClassDocImpl getInstance(ClassDoc outerDoc, TypeDec typeDec) { - return factory.getInstance(outerDoc, typeDec); - } - - /** - * Returns the known ClassDocImpl for a given String -- - * the returned value may be null. - * - * @return the known ClassDocImpl for a given String -- - * the returned value may be null. - */ - public final static ClassDocImpl find(String qualifiedName) { - return factory.find(qualifiedName); - } - - /**The factory used to create instances of this class. */ - private final static Factory factory = new Factory(); - - /** The ClassDec to which is delegated. */ - private final TypeDec typeDec; - - // todo: we know these Collections are FilteredDecList, so declare that? - /** The introductions that affect a ClassDoc. */ - private Collection introducers; - - /** The array of fields visible in this type. */ - private Collection fieldDocs; - - /** The array of methods visible in this type. */ - private Collection methodDocs; - - /** The array of constructors visible in this type. - * The implementation must support iterator().remove(). - */ - private Collection constructorDocs; - - /** The array of inner classes visible in thie type. */ - private Collection innerclassDocs; - - /** The array of interfaces this type implements. */ - private Collection interfaceDocs; - - /** The array of classes this type imports on demand. */ - private Collection importedClasses; - - /** The array of package this type imports on demand. */ - private Collection importedPackages; - - /** The array of pointcuts visible in this type. */ - private Collection pointcutDocs; - - /** cached variant of ((AjdocCompiler)ajc()).getFilter() */ - private AccessChecker filter; - - /** - * Constructs a representation of an AspectJ-compiled class - * using the underlying TypeDec and containning ClassDoc. - * NOTE: This is protected (and maybe should be private) - * because the static method {@link #getInstance(TypeDec)} - * should always be used to get instances of this type. It - * ensures that enclosing types are created before their - * enclosed types. - * - * @param containingClass ClassDoc that encloses this. - * @param typeDec The underlying TypeDec. - */ - protected ClassDocImpl(com.sun.javadoc.ClassDoc containingClass, - TypeDec typeDec) { - super(containingClass); - this.typeDec = typeDec; - //AccessChecker check = getFilter(); - // RootDocImpl sets inclusion of world classes - setIncluded(false); - // have to install before creating imports to avoid cycles - factory.put(this, typeDec); - createImports(importedClasses = new ArrayList(), - importedPackages = new ArrayList()); - } - - /** - * Maps Decs to their counterpart by testing with - * instanceof - * - * @return a MemberDocImpl that has an underlying Dec dec. - */ - public MemberDocImpl docForDec(Dec dec) { - if (dec instanceof FieldDec) { - return docForDec((FieldDec)dec); - } - if (dec instanceof CodeDec) { - return docForDec((CodeDec)dec); - } - // todo: map for inner classes, Type, etc? - return null; //TODO error ??? - } - - /** - * Returns a FieldDocImpl that has an underlying FieldDec dec. - * - * @return a FieldDocImpl that has an underlying FieldDec dec. - */ - public FieldDocImpl docForDec(FieldDec dec) { - FieldDoc[] fs = fields(); - for (int i = 0; i < fs.length; i++) { - FieldDocImpl fd = (FieldDocImpl)fs[i]; - if (fd.dec() == dec) return fd; - } - return null; - } - - /** - * Returns a CodeDocImpl that has an underlying CodeDec dec. - * - * @return a CodeDocImpl that has an underlying CodeDec dec. - */ - public CodeDocImpl docForDec(CodeDec dec) { - MethodDoc[] ms = methods(); - for (int i = 0; i < ms.length; i++) { - CodeDocImpl cd = (CodeDocImpl)ms[i]; - if (cd.dec() == dec) return cd; - } - ConstructorDoc[] cs = constructors(); - for (int i = 0; i < cs.length; i++) { - CodeDocImpl cd = (CodeDocImpl)cs[i]; - if (cd.dec() == dec) return cd; - } - return null; - } - - /** - * @todo ?????? - */ - public TypeDec nonNullTypeDec() { - if (typeDec().getLexicalType() == null) return typeDec(); - return super.nonNullTypeDec(); - } - - /** - * Returns a Collection of ClassDocImpls that have corresponding - * ClassDecs declared within classDec(). - * - * @return a Collection of ClassDocImpls that have corresponding - * ClassDecs declared within classDec(). - */ - private Collection createInnerTypes() { - Collection items = ((NameType)typeDec.getType()).getInnerTypes(); - FilteredDecList result = - new FilteredDecList(getFilter(), this); - if (items != null) { - for (Iterator i = items.iterator(); i.hasNext();) { - result.add(((NameType)i.next()).getTypeDec()); - } - } - Collections.sort(result); - return result; - } - - /** - * Creates the two collection of imports -- class and packages -- - * used by the file in which classDec() was declared. - * - * @param importClasses the classes to fill. - * @param importPkgs the packages to fill. - */ - private void createImports(final Collection importClasses, - final Collection importPkgs) { - CompilationUnit cu = typeDec.getCompilationUnit(); - if (cu != null) { - Imports imports = cu.getImports(); - if (imports != null) { - for (int i = 0; i < imports.size(); i++) { - Import imprt = imports.get(i); - if (imprt != null) { - if (imprt.getStar()) { - PackageDoc importedPkg = - PackageDocImpl.getPackageDoc - (imprt.getName()); - if (importedPkg != null) { - importPkgs.add(importedPkg); - } - } else { - com.sun.javadoc.ClassDoc importedClass = - findClass(imprt.getName()); - if (importedClass != null) { - importClasses.add(importedClass); - } - } - } - } - } - } - } - - /** - * Returns a Collection of ClassDocImpl representing the - * interfaces the underlying TypeDec implements. - * - * @return a Collection of ClassDocImpl representing the - * interfaces the underlying TypeDec implements. - */ - private Collection createInterfaces() { - //NameType type = (NameType)typeDec.getType(); - Collection items = typeDec.getSuperInterfaceTypes(); - FilteredDecList result = - new FilteredDecList(getFilter(), this); - if (items != null) { - for (Iterator i = items.iterator(); i.hasNext();) { - result.add(((NameType)i.next()).getTypeDec()); - } - } - Collections.sort(result); - return result; - } - - /** - * Called by AjdocCompiler to do pruning once the whole world is created. - * This avoids using aspect before initialized when - * this classdoc constructed as a result of aspect - * initialization. - */ - void postProcess() { - // prune compiler-generated default constructor if unadvised. - // can't do this on construction since advising aspect may exist but be uninitialized - final SourceLocation parentLoc = dec().getSourceLocation(); - final int parentLine = (null == parentLoc ? -1 : parentLoc.getBeginLine()); - final int parentColumn = (null == parentLoc ? -1 : parentLoc.getBeginColumn()); - if (null == constructorDocs) { - if (null == constructors()) { - // XXX harmless error System.err.println("Unable to post-process"); - return; - } - } - try { - //ArrayList removed = new ArrayList(); - for (Iterator i = constructorDocs.iterator(); i.hasNext(); ) { - ConstructorDocImpl cdi = (ConstructorDocImpl) i.next(); - CodeDec cd = cdi.codeDec(); - SourceLocation sl = (null == cd ? null : cd.getSourceLocation()); - // if ajc changes so typedec start/end not equal to constructor, then can't recognize - if ((null != sl) - && (parentColumn == sl.getBeginColumn()) - && (parentLine == sl.getBeginLine())) { - Object[] advice = cdi.advice(); - if ((null != advice) && (1 > advice.length)) { - i.remove(); - //removed.add(cdi); - //System.err.println("removing unadvised generated constructor: " + cdi); - } else { - //System.err.println("keeping advised generated constructor: " + cdi); - } - } else { - //System.err.println("keeping ungenerated constructor: " + cdi); - } - } -// for (Iterator i = removed.iterator(); i.hasNext();) { -// Object dec = i.next(); -// if (constructorDocs.contains(dec)) { -// throw new Error("remove failed for " + dec); -// } -// } - } catch (UnsupportedOperationException e) { - System.err.println("Warning: ClassDocImpl.constructorDocs not removable"); - } - } - - /** - * Returns a Collection of ConstructorDocImpl representing the - * constructors the underlying TypeDec declares. - * - * @return a Collection of ConstructorDocImpl representing the - * constructors the underlying TypeDec declares. - */ - private Collection createConstructors() { - NameType type = (NameType)typeDec.getType(); - Collection items = type.getConstructors(); - final SourceLocation parentLoc = dec().getSourceLocation(); - final int parentLine = (null == parentLoc ? -1 : parentLoc.getBeginLine()); - final int parentColumn = (null == parentLoc ? -1 : parentLoc.getBeginColumn()); - FilteredDecList result = - new FilteredDecList(getFilter(), this); - if (items != null) { - for (Iterator i = items.iterator(); i.hasNext();) { - Constructor c = (Constructor) i.next(); - ConstructorDec cd = c.getConstructorDec(); - ConstructorDocImpl impl = new ConstructorDocImpl(this, cd); - // XXX workaround for ajc bug of default constructor source location - SourceLocation sl = (null == cd ? null : cd.getSourceLocation()); - // if line/column starts the same, then a generated constructor - if ((null != sl) - && (parentColumn == sl.getBeginColumn()) - && (parentLine == sl.getBeginLine())) { - // use source location clone without comment from class - TextSourceLocation tsl = new TextSourceLocation(sl.getCompilationUnit(), - sl.getStartPosition(), sl.getEndPosition()); - tsl.clearComment(); - cd.setSourceLocation(tsl); - } - result.add(impl); - } - } - Collections.sort(result); - return result; - } - - /** - * Returns a Collection of PointcutDocImpl representing the - * pointcuts the underlying TypeDec declares. - * - * @return a Collection of PointcutDocImpl representing the - * pointcuts the underlying TypeDec declares. - */ - private Collection createPointcuts() { - NameType type = (NameType)typeDec.getType(); - Collection items = type.getPointcuts(); - FilteredDecList result = - new FilteredDecList(getFilter(), this); - if (items != null) { - for (Iterator i = items.iterator(); i.hasNext();) { - result.add(((PointcutSO)i.next()).getPointcutDec()); - } - } - Collections.sort(result); - return result; - } - - /** - * Returns a Collection of MethodDocImpl representing the - * methods the underlying TypeDec declares. - * - * @return a Collection of MethodDocImpl representing the - * methods the underlying TypeDec declares. - */ - private Collection createMethods() { - NameType type = (NameType)typeDec.getType(); - Collection methods = type.getMethods(); - FilteredDecList result = - new FilteredDecList(getFilter(), this); - if (methods != null) { - for (Iterator i = methods.iterator(); i.hasNext();) { - result.add(((Method)i.next()).getMethodDec()); - } - } - Collections.sort(result); - return result; - } - - /** - * Returns a Collection of FieldDocImpl representing the - * fields the underlying TypeDec declares. - * - * @return a Collection of FieldDocImpl representing the - * fields the underlying TypeDec declares. - */ - private Collection createFields() { - NameType type = (NameType)typeDec.getType(); - Collection fields = type.getFields(); - FilteredDecList result = - new FilteredDecList(getFilter(), this); - if (fields != null) { - for (Iterator i = fields.iterator(); i.hasNext();) { - result.add(((Field)i.next()).getFieldDec()); - } - } - Collections.sort(result); - return result; - } - - /** return (and cache) filter from ajc() */ - protected AccessChecker getFilter() { - // nb: called during construction - if (null == filter) { - AspectJCompiler ajc = ajc(); - if (ajc instanceof AjdocCompiler) { - filter = ((AjdocCompiler) ajc).getFilter(); - } - } - return filter; // still may be null - } - - /** - * Returns the underlying Dec -- a TypeDec. - * - * @return the underlying Dec -- a TypeDec. - */ - protected final Dec dec() { - return typeDec(); - } - - /** - * Returns the underlying TypeDec. - * - * @return the underlying TypeDec. - */ - public final TypeDec typeDec() { - return typeDec; - } - - /** - * Returns the fully-qualified name of this TypeDec including - * the package and any enclosing classes. - * - * @return the fully-qualified name of this TypeDec including - * the package and any inclosing classes. - */ - public String qualifiedName() { - return qualifiedTypeName().replace('$','.'); - } - - /** - * Returns the fully-qualfied name of this class. - * - * @return the fully-qualfied name of this class. - */ - public String toString() { - return qualifiedName(); - } - - /** - * Returns the single name of this TypeDec excluding the package - * but including enclosing classes. NOTE: All dollar signs - * are replaced by periods. - * - * @return the single name of this TypeDec excluding the package - * but including enclosing classes. - */ - public String name() { - return ((NameType)typeDec().getType()). - getExtendedId().replace('$','.'); - } - - /** - * Returns the class specified by classname - * from the context of this. This method may return - * null denoting the class wasn't found. - * Search proceeds in the following order: - * - *

- * - * @return the type specified by classname - * from the context of this. - * @see Util#findClass(ClassDoc,String,JavaCompiler) - * @see - * Javadoc Tool Homepage - */ - public com.sun.javadoc.ClassDoc findClass(String classname) { - // Sanity check - if (classname == null || classname.length() < 1) { - return null; - } - - // The result - com.sun.javadoc.ClassDoc desired; - - // [0] The trivial case, the classname is this class - if (classname.equals(name()) || - classname.equals(qualifiedName())) { - return this; - } - - // [1] Look up the fully qualified name. - if ((desired = ClassDocImpl.find(classname)) != null) { - return desired; - } - - // [2] Search the inner classes. We can assume that if - // classname refers to an inner class it is unqualified - // with respect to its package, because step [1] would have - // picked it up, then. First look to see if the name - // matches, then search the inner class itself. We check two - // values: - // [1] innername: the unqualified inner class name - // [2] classname: the qualified (with outer class) name - // Example: - // /** - // * @see Inner - // * // classname == Inner (f'cked) - // * // innername == Outer.Inner (ok) - // * @see Outer.Inner - // * // classname == Outer.Inner (ok) - // * // innername == Outer.Outer.Inner (f'cked) - // class Outer { - // static class Inner {} - // } - String innername = name() + '.' + classname; - com.sun.javadoc.ClassDoc[] inners = innerClasses(); - if (inners != null) { - for (int i = 0; i < inners.length; i++) { - if (classname.equals(inners[i].name()) || - innername.equals(inners[i].name())) { - return inners[i]; - } - } - } - - // [3] Search in this package - if ((desired = containingPackage().findClass(classname)) != null) { - return desired; - } - - // [4] Search the class imports. The order for this is specified - // by the compiler -- if you don't believe me read for yourself: - // http://java.sun.com/products/jdk/1.2/docs/tooldocs/win32/ (cont't) - // javadoc.html#seesearchorder - // We don't look in other package, so we assume classname - // is full package-qualified. - com.sun.javadoc.ClassDoc[] imports = importedClasses(); - if (imports != null) { - for (int i = 0; i < imports.length; i++) { - if (classname.equals(imports[i].name())) { - return imports[i]; - } - } - } - - // [5] Search the package imports for the fully-qualified name. - PackageDoc[] pkgs = importedPackages(); - if (pkgs != null) { - for (int i = 0; i < pkgs.length; i++) { - if ((desired = pkgs[i].findClass(classname)) != null) { - return desired; - } - } - } - - // [5 1/2] OK, I lied above, we do search a couple packages, - // it should be java.lang, but we're aspectj, so we'll look in - // org.aspectj.lang, too. We assume the names are package-unqualified - // in this step. - // TODO: check that this is made final, if not, make it static - String[] pkgnames = {"java.lang", "org.aspectj.lang"}; - for (int i = 0; i < pkgnames.length; i++) { - PackageDoc pkg = PackageDocImpl.getPackageDoc(pkgnames[i]); - if (pkg != null) { - if ((desired = pkg.findClass(classname)) != null) { - return desired; - } - } - } - // Found nothing. - return null; - } - - /** - * Returns the fields visible in this type. - * - * @return an array of FieldDoc representing - * the fields visible in this type. - */ - public FieldDoc[] fields() { - if (fieldDocs == null) { - fieldDocs = createFields(); - } - return (FieldDoc[])fieldDocs.toArray - (new org.aspectj.ajdoc.FieldDoc[fieldDocs.size()]); - } - - /** - * Returns true is this type is externalizable. - * - * @return true is this type is externalizable. - */ - public boolean isExternalizable() { - return false; //TODO - } - - /** - * Returns true if this type is serializable. - * - * @return true if this type is serializable. - */ - public boolean isSerializable() { - for (Iterator i = typeDec().getSuperInterfaceTypes().iterator(); - i.hasNext();) { - if (((Type)i.next()).getId().equals("java.io.Serializable")) { - return true; - } - } - return false; - } - - /** - * Returns the methods visible in this type. - * - * @return an array of MethodDoc representing the - * methods visible in this type. - */ - public MethodDoc[] methods() { - if (methodDocs == null) { - methodDocs = createMethods(); - } - return (MethodDoc[])methodDocs.toArray - (new org.aspectj.ajdoc.MethodDoc[methodDocs.size()]); - } - - /** - * Returns the serializable methods visible in this type. - * - * @return an array of MethodDoc representing the - * serializable methods visible in this type. - */ - public MethodDoc[] serializationMethods() { - List ser = new ArrayList(); - MethodDoc[] mds = methods(); - for (int i = 0, N = mds.length; i < N; i++) { - if (mds[i].tags("@serialized").length > 1) ser.add(mds[i]); - } - return (MethodDoc[])ser.toArray(new MethodDoc[ser.size()]); - } - - /** - * Returns the serializable fields visible in this type. - * - * @return an array of MethodDoc representing the - * serializable fields visible in this type. - */ - public FieldDoc[] serializableFields() { - List ser = new ArrayList(); - FieldDoc[] fds = fields(); - for (int i = 0, N = fds.length; i < N; i++) { - if (fds[i].serialFieldTags().length > 1) ser.add(fds[i]); - } - return (FieldDoc[])ser.toArray(new FieldDoc[ser.size()]); - } - - /** - * Returns true is this type contains - * visible serializable fields. - * - * @return true is this type contains - * visible serializable fields. - */ - public boolean definesSerializableFields() { - return serializableFields().length > 0; - } - - /** - * Returns the super type of this type. The return value - * is guaranteed to be non-null unless this represents - * java.lang.Object. - * - * @return a ClassDoc representing the super type of this type. - * or null if this represents java.lang.Object. - */ - public com.sun.javadoc.ClassDoc superclass() { - if ("java.lang.Object".equals(qualifiedTypeName())) { - return null; - } else { - TypeDec superType = typeDec().getSuperClassType().getTypeDec(); - return ClassDocImpl.getInstance(superType); - } - } - - /** - * Returns true is c is a - * subtype of this. - * - * @return true is c is a - * subtype of this. - */ - public boolean subclassOf(com.sun.javadoc.ClassDoc c) { - return c != null && c.equals(superclass()); - } - - /** - * Returns the interfaces this type implements. - * - * @return an array of ClassDoc representing the - * interfaces this type implements. - */ - public com.sun.javadoc.ClassDoc[] interfaces() { - if (interfaceDocs == null) { - interfaceDocs = createInterfaces(); - } - return (ClassDoc[])interfaceDocs.toArray - (new org.aspectj.ajdoc.ClassDoc[interfaceDocs.size()]); - } - - /** - * Returns the constructors visible in this type. - * - * @return an array of ConstructorDoc representing the - * visible constructors in this type. - */ - public ConstructorDoc[] constructors() { - if (constructorDocs == null) { - constructorDocs = createConstructors(); - } - return (ConstructorDoc[])constructorDocs.toArray - (new org.aspectj.ajdoc.ConstructorDoc[constructorDocs.size()]); - } - - /** - * Returns the inner class visible in this type. - * - * @return an array of ClassDoc representing the inner - * classes visible in this type. - */ - public com.sun.javadoc.ClassDoc[] innerClasses() { - if (innerclassDocs == null) { - innerclassDocs = createInnerTypes(); - } - final int size = innerclassDocs.size(); - return (ClassDoc[])innerclassDocs.toArray - (new org.aspectj.ajdoc.ClassDoc[size]); - } - - /** - * Returns the types imported on demand by this type. - * - * @return an array of ClassDoc representing the - * types imported on demand by this type. - */ - public com.sun.javadoc.ClassDoc[] importedClasses() { - return (ClassDoc[])importedClasses.toArray - (new org.aspectj.ajdoc.ClassDoc[importedClasses.size()]); - } - - /** - * Returns the packages imported on demand by this type. - * - * @return an array of PackageDoc representing the - * packages imported on demand by this type. - */ - public PackageDoc[] importedPackages() { - return (PackageDoc[])importedPackages.toArray - (new org.aspectj.ajdoc.PackageDoc[importedPackages.size()]); - } - - /** - * Returns the pointcuts visible in this type. - * - * @return an array of PointcutDoc representing the - * pointcuts visible in this type. - */ - public PointcutDoc[] pointcuts() { - if (pointcutDocs == null) { - pointcutDocs = createPointcuts(); - } - return (PointcutDoc[])pointcutDocs.toArray - (new PointcutDoc[pointcutDocs.size()]); - } - - /** - * Returns true is this type is abstract. - * - * @return true is this type is abstract. - */ - public boolean isAbstract() { - return typeDec().isAbstract(); - } - - /** - * Returns true is this type is as exception. - * - * @return true is this type is an instance - * of java.lang.Exception. - */ - public boolean isException() { - //TODO: make lazy - for (com.sun.javadoc.ClassDoc superclass = superclass(); - superclass != null && - !superclass.qualifiedTypeName().equals("java.lang.Object"); - superclass = superclass.superclass()) { - if (superclass.qualifiedTypeName().equals("java.lang.Exception")) { - return true; - } - } - return false; - } - - /** - * Returns true is this type is an error. - * - * @return true is this type is an instance - * of java.lang.Error. - */ - public boolean isError() { - //TODO: make lazy - for (com.sun.javadoc.ClassDoc superclass = superclass(); - superclass != null && - !superclass.qualifiedTypeName().equals("java.lang.Object"); - superclass = superclass.superclass()) { - if (superclass.qualifiedTypeName().equals("java.lang.Error")) { - return true; - } - } - return false; - } - - /** - * Returns the introductions affecting a ClassDoc's - * type hierarchy. - * - * @return an array of IntroducedSuperDoc representing the - * introductions of this ClassDoc that affect its - * type hierarchy. - */ - public IntroducedSuperDoc[] introducers() { - if (introducers == null) { - introducers = createIntroducers(); - } - return (IntroducedSuperDoc[])introducers.toArray - (new IntroducedSuperDoc[introducers.size()]); - } - - /** - * Returns true is this is an interface. - * - * @return true is this is an interface. - */ - public boolean isInterface() { - return typeDec() instanceof InterfaceDec; - } - - /** - * Returns true is this is a class. - * - * @return true is this is a class. - */ - public boolean isClass() { - return typeDec() instanceof ClassDec; - } - - /** - * Returns true is this is an aspect. - * - * @return true is this is an aspect. - */ - public boolean isAspect() { - return typeDec() instanceof AspectDec; - } - - /** - * Returns true is this class is neither - * an error nor an exception, but this still could be - * an aspect. - * - * @return true is this class is neither - * an error nor an exception, but this still could be - * an aspect. - */ - public boolean isOrdinaryClass() { - return isClass() && !(isError() || isException()); - } - - /** - * Returns int modifiers with the 'interface' bit set. - * - * @return int modifiers with the 'interface' bit set. - * @see java.lang.reflect.Modifier. - */ - public int modifierSpecifier() { - return super.modifierSpecifier() - | (isInterface() ? Modifier.INTERFACE : 0); - } - - - /* ------------------------------------------------------------ - * Implementation of Type - * ------------------------------------------------------------ - */ - - /** - * Returns the declaration of this type -- null if - * this isn't included. - * - * @return the ClassDoc represented by this Type or null - * if this isn't included. - */ - public com.sun.javadoc.ClassDoc asClassDoc() { - return isIncluded() ? this : null; - } - - /** - * Returns this type's dimension information as a String. - * - * @return this type's dimension information as a String. - */ - public String dimension() { - return ""; - } - - /** - * Returns qualified name of type excluding - * any dimension information. - * - * @return qualified name of type excluding - * any dimension information. - */ - public String qualifiedTypeName() { - return typeDec().getFullName().replace('$', '.'); - } - - /** - * Returns unqualified name of type excluding - * any dimension information. - * - * @return unqualified name of type excluding - * any dimension information. - */ - public String typeName() { - return typeDec().getId().replace('$', '.'); - } - - /** - * Returns the Collection of IntroducedSuperDec that - * introduce a type intro this's type hierarchy. At the - * same time, the method makes sure this is - * added to every IntroducedSuperDec's list of targets. - * - * @return Collection of IntroducedSuperDec that - * introduce a type intro this's type hierarchy. - */ - private Collection createIntroducers() { - Set affectedBy = ajc().getCorrespondences().getAffectedBy(typeDec); - if (affectedBy.size() < 1) { - return Collections.EMPTY_LIST; - } - Collection list = new ArrayList(); - for (Iterator i = affectedBy.iterator(); i.hasNext();) { - Object o = i.next(); - if (o instanceof IntroducedSuperDec) { - IntroducedSuperDec dec = (IntroducedSuperDec)o; - TypeDec owner = ((NameType)dec.getDeclaringType()).getTypeDec(); - AspectDocImpl ad = (AspectDocImpl)ClassDocImpl.getInstance(owner); - IntroducedSuperDocImpl id = (IntroducedSuperDocImpl)ad.introDocForDec(dec); - list.add(id); - id.addTarget(this); - - } - } - return list; - } - - - /* ------------------------------------------------------------ - * Factory instantiation - * ------------------------------------------------------------ - */ - - /** - * Inner class in charge of creating instances of ClassDocImpl. - */ - private final static class Factory { - - private final Map typeDecsToClassDocs = new HashMap(); - private final Map qualifiedNamesToClassDocs = new HashMap(); - - public final ClassDocImpl find(String qualifiedName) { - return (ClassDocImpl)qualifiedNamesToClassDocs.get(qualifiedName); - } - - public final ClassDocImpl getInstance(TypeDec typeDec) { - if (typeDec == null) return null; - ClassDocImpl outerDoc = getInstance(typeDec.getEnclosingTypeDec()); - - return getInstance(outerDoc, typeDec); - } - public final ClassDocImpl getInstance(ClassDoc outerDoc, - TypeDec typeDec) { - if (typeDec == null) return null; - ClassDocImpl cd = (ClassDocImpl)typeDecsToClassDocs.get(typeDec); - if (cd == null) { - cd = makeInstance(outerDoc, typeDec); - /* - Object o = typeDecsToClassDocs.put(typeDec, cd); - if (null != o) { - throw new Error("new " + cd + " displaced " + o + " for " + typeDec); - } - */ - } - return cd; - } - private final ClassDocImpl makeInstance(ClassDoc outerDoc, - TypeDec typeDec) { - ClassDocImpl result = null; - if (typeDec instanceof AspectDec) { - result = new AspectDocImpl(outerDoc, (AspectDec)typeDec); - } else { - result = new ClassDocImpl(outerDoc, typeDec); - } - if (null == result.containingPackage()) { - System.err.println("Warning: unable to add " - + result + " to package"); - } - return result; - } - - /** - * constructor installs itself here before generating imports. - * fyi: not Thread-safe since available from factory before - * construction completes - * @return object displaced, if any - error if not null - */ - private final Object put(ClassDocImpl classdoc, TypeDec typeDec) { - Object result = typeDecsToClassDocs.put(typeDec, classdoc); - if (null == result) { - result = qualifiedNamesToClassDocs.put(classdoc.qualifiedName(), classdoc); - } - return result; - } - } // factory -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/CodeDocImpl.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/CodeDocImpl.java deleted file mode 100644 index b2de78140..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/CodeDocImpl.java +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.ajdoc; - -import org.aspectj.compiler.base.ast.ASTObject; -import org.aspectj.compiler.base.ast.CodeDec; -import org.aspectj.compiler.base.ast.Dec; -import org.aspectj.compiler.base.ast.DummySourceLocation; -import org.aspectj.compiler.base.ast.Formals; -import org.aspectj.compiler.base.ast.NameType; -import org.aspectj.compiler.base.ast.SourceLocation; -import org.aspectj.compiler.base.ast.TypeDec; -import org.aspectj.compiler.base.ast.TypeDs; -import org.aspectj.compiler.crosscuts.ast.AdviceDec; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -public abstract class CodeDocImpl extends ExecutableMemberDocImpl { - - /** The CodeDec to which we delegate. */ - private final CodeDec codeDec; - - public CodeDocImpl(com.sun.javadoc.ClassDoc containingClass, CodeDec codeDec) { - super(containingClass); - this.codeDec = codeDec; - } - - protected Collection createAdvice() { - Set affectedBy = ajc().getCorrespondences().getAffectedBy(codeDec()); - if (affectedBy.size() < 1) return Collections.EMPTY_LIST; - List list = new ArrayList(); - for (Iterator i = affectedBy.iterator(); i.hasNext();) { - AdviceDec adec = (AdviceDec)i.next(); - TypeDec owner = ((NameType)adec.getDeclaringType()).getTypeDec(); - AspectDocImpl ad = (AspectDocImpl)ClassDocImpl.getInstance(owner); - AdviceDocImpl adoc = ad.docForDec(adec); - list.add(adoc); - } - return list; - } - - protected Dec dec() { - return codeDec(); - } - - protected Formals getFormals() { - return codeDec().getFormals(); - } - - protected TypeDs getThrows() { - return codeDec().getThrows(); - } - - protected CodeDec codeDec() { - return codeDec; - } -} - diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/Comment.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/Comment.java deleted file mode 100644 index 55655941a..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/Comment.java +++ /dev/null @@ -1,336 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.ajdoc; - -import com.sun.javadoc.Doc; -import com.sun.javadoc.ParamTag; -import com.sun.javadoc.SeeTag; -import com.sun.javadoc.SerialFieldTag; -import com.sun.javadoc.Tag; -import com.sun.javadoc.ThrowsTag; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; - -public class Comment { - - /** The parsed comment text. */ - private String commentText; - - /** The raw comment text. */ - private String rawCommentText; - - /** The list of tags. */ - private List tags; - - /** The Doc to which the Comment belongs. */ - private Doc doc; - - /** The Locale in which this comment resides. */ - private Locale loc; - - /** The ErrPrinter used by this Comment to output messages. */ - private ErrPrinter err; - - public Comment(Doc doc, String formalComment) { - this(doc, formalComment, ErrPrinter.instance); - } - - public Comment(Doc doc, String formalComment, ErrPrinter err) { - this(doc, formalComment, err, Locale.US); - } - - public Comment(Doc doc, String formalComment, ErrPrinter err, Locale loc) { - this.rawCommentText = Util.rawCommentText(formalComment); - this.commentText = Util.commentText(rawCommentText); - this.doc = doc; - this.err = err; - this.loc = loc; - } - - /** - * Returns the parsed comment text. - * - * @return the parsed comment text. - */ - public String commentText() { - return commentText; - } - - /** - * Returns the full unprocessed text of the comment. - * - * @return the full unprocessed text of the comment. - */ - public String getRawCommentText() { - return rawCommentText; - } - - /** - * Sets the comment text. - * - * @param commentText the new comment text. - */ - public void setCommentText(String commentText) { - this.commentText = commentText; - } - - /** - * Returns the raw comment text. - * - * @return the raw comment text. - */ - public String rawCommentText() { - return rawCommentText; - } - - /** - * Sets the raw comment text. - * - * @param rawCommentText the new raw comment text. - */ - public void setRawCommentText(String rawCommentText) { - this.rawCommentText = rawCommentText; - } - - /** - * Returns all this comment's tags. - * - * @return a List of tags whose elements are Comment instances - */ - public List getTags() { - if (tags == null) { - tags = findTags(); - } - return tags; - } - - /** - * Sets the Doc for this comment. - * - * @param doc the new Doc. - */ - public void setDoc(Doc doc) { - this.doc = doc; - } - - /** - * Returns the Doc for this comment. - * - * @return the Doc for this comment. - */ - public Doc doc() { - return doc; - } - - /** - * Sets the locale for this comment. - * - * @param loc the new locale for this comment. - */ - public void setLocale(Locale loc) { - this.loc = loc; - } - - /** - * Returns the Locale for this comment. - * - * @return the Locale for this comment. - */ - public Locale locale() { - return loc; - } - - /** - * Sets the ErrPrinter for this comment. - * - * @param err the new ErrPrinter for this comment. - */ - public void setErr(ErrPrinter err) { - this.err = err; - } - - /** - * Returns the ErrPrinter for this comment. - * - * @return the ErrPrinter for this comment. - */ - public ErrPrinter err() { - return err; - } - - /** - * Initializes the Doc, Locale, and ErrPrinter. - * - * @param doc the new Doc. - * @param loc the new Locale. - * @param err the new ErrPrinter. - */ - public void init(Doc doc, Locale loc, ErrPrinter err) { - setDoc(doc); - setLocale(loc); - setErr(err); - } - - /** - * Returns the comment as an array of Tag. - * - * @return an array of Tag representing the comment. - */ - public Tag[] inlineTags() { - return Util.inlineTags(doc(), - commentText(), - locale(), - err()); - } - - /** - * Returns all tags of the comment whose name equals - * tagname. - * - * @return an array of Tag representing all tags of the - * comment whose name equals tagname. - */ - public Tag[] tags(String type) { - type = type.startsWith("@") ? type : "@"+type; - List result = new ArrayList(); - Tag tag; - for (Iterator i = getTags().iterator(); i.hasNext();) { - if ((tag = (Tag)i.next()).kind().equals(type)) { - result.add(tag); - } - } - return (Tag[])result.toArray(new Tag[result.size()]); - } - - /** - * Returns the param tags describing parameters taken - * by this code. - * - * @return an array of ParamTag representing the - * parameters taken by this code. - */ - public ParamTag[] paramTags() { - List result = new ArrayList(); - Tag tag; - for (Iterator i = getTags().iterator(); i.hasNext();) { - if ((tag = (Tag)i.next()) instanceof ParamTag) { - result.add((ParamTag)tag); - } - } - return (ParamTag[])result.toArray(new ParamTag[result.size()]); - } - - /** - * Returns the see tags of the comment. - * - * @return an array of SeeTag representing the - * see tags of the comment. - */ - public SeeTag[] seeTags() { - List result = new ArrayList(); - Tag tag; - for (Iterator i = getTags().iterator(); i.hasNext();) { - if ((tag = (Tag)i.next()) instanceof SeeTag) { - result.add((SeeTag)tag); - } - } - return (SeeTag[])result.toArray(new SeeTag[result.size()]); - } - - /** - * Returns the serial field tags for this field. - * - * @return an array of SerialFieldTag representing the - * serial field tags for this field. - */ - public SerialFieldTag[] serialFieldTags() { - List result = new ArrayList(); - Tag tag; - for (Iterator i = getTags().iterator(); i.hasNext();) { - if ((tag = (Tag)i.next()) instanceof SerialFieldTag) { - result.add((SerialFieldTag)tag); - } - } - return (SerialFieldTag[])result.toArray - (new SerialFieldTag[result.size()]); - } - - /** - * Returns the throw tags describing exceptions thrown - * declared by this code. - * - * @return an array of ThrowsTag representing the exception - * this code declares to throw. - */ - public ThrowsTag[] throwsTags() { - List result = new ArrayList(); - Tag tag; - for (Iterator i = getTags().iterator(); i.hasNext();) { - if ((tag = (Tag)i.next()) instanceof ThrowsTag) { - result.add((ThrowsTag)tag); - } - } - return (ThrowsTag[])result.toArray - (new ThrowsTag[result.size()]); - } - - /** - * Returns all tags of the comment. - * - * @return an array of Tag representing all - * tags of the comment. - */ - public Tag[] tags() { - return (Tag[])getTags().toArray - (new Tag[getTags().size()]); - } - - /** - * Returns the Tags that comprise the first - * sentence of the comment. - * - * @return an array of Tag representing the first - * sentence of the comment. - */ - public Tag[] firstSentenceTags() { - return Util.firstSentenceTags(doc(), - commentText(), - locale(), - err()); - } - - /** - * Used to lazily initialize the tags of this comment. - * - * @return a List of tags whose elements of Tag instances - * and each represent a tag in this comment. - */ - private List findTags() { - return Util.findTags(doc(), - rawCommentText(), - locale(), - err()); - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/ConstructorDocImpl.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/ConstructorDocImpl.java deleted file mode 100644 index b9bb4d324..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/ConstructorDocImpl.java +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.ajdoc; - -import org.aspectj.compiler.base.ast.ConstructorDec; - -import com.sun.javadoc.ClassDoc; - -public class ConstructorDocImpl - extends CodeDocImpl - implements org.aspectj.ajdoc.ConstructorDoc { - - public ConstructorDocImpl(ClassDoc containingClass, ConstructorDec constructor) { - super(containingClass, constructor); - } - - /** - * Returns true. - * - * @return true. - */ - public boolean isConstructor() { - return true; - } - - /** - * Returns the fully-qualified name -- i.e. the - * defining types ID. - * - * @return the fully-qualified name -- i.e. the - * defining types ID. - */ - public String qualifiedName() { - return containingClass().name(); - } - - /** - * Returns the name of this -- i.e. the qualified name. - * - * @return the name of this -- i.e. the qualified name. - */ - public String name() { - return qualifiedName(); - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/DocImpl.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/DocImpl.java deleted file mode 100644 index 87dad677e..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/DocImpl.java +++ /dev/null @@ -1,280 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.ajdoc; - -import org.aspectj.ajdoc.Doc; - -import com.sun.javadoc.SeeTag; -import com.sun.javadoc.Tag; - -import java.util.Locale; - -public abstract class DocImpl - implements org.aspectj.ajdoc.Doc { - - /** Keep track of whether this is included or not. */ - private boolean isIncluded = true; - - /** The comment for this Doc. */ - private Comment comment; - - /** The error printer for this Doc. */ - private ErrPrinter err; - - /** Keep track of whether this is included or not. */ - private boolean isInterface = true; - - /** The locale of the object -- default to Locale.US. */ - private Locale locale = Locale.US; //TODO - - /** - * Returns the locale. - * - * @return the locale. - */ - public Locale locale() { //XXX - return locale; - } - - - public void setErr(ErrPrinter err) { this.err = err; } - public ErrPrinter err() { return ErrPrinter.instance; } - - public void setComment(Comment comment) { this.comment = comment; } - public Comment getComment() { return comment; } - - /** - * Delegates to {@link Util#compareTo(Object)} to compare - * with another Object. - * - * @return a negative integer, zero, or a positive integer - * as this object is less than, equal to, or greater - * than the specified object based on name. - * @see java.lang.Comparable.compareTo(Object) - */ - public int compareTo(Object other) { - return other instanceof Doc - ? Util.compareTo(this, (Doc)other) - : -1; - } - - /** - * Returns the Tags that comprise the first - * sentence of the comment. - * - * @return an array of Tag representing the first - * sentence of the comment. - */ - public Tag[] firstSentenceTags() { - return getComment() != null - ? getComment().firstSentenceTags() - : new Tag[0]; - } - - /** - * Returns the full unprocessed text of the comment. - * - * @return the full unprocessed text of the comment. - */ - public String getRawCommentText() { - return getComment() != null - ? getComment().rawCommentText() - : ""; - } - - /** - * Sets the full unprocessed text of the comment. - * - * @param rawCommentText the new full unprocessed text of the comment.. - */ - public void setRawCommentText(String rawCommentText) { - if (getComment() != null) { - getComment().setRawCommentText(rawCommentText); - } - } - - /** - * Returns the comment as an array of Tag. - * - * @return an array of Tag representing the comment. - */ - public Tag[] inlineTags() { - return getComment() != null - ? getComment().inlineTags() - : new Tag[0]; - } - - /** - * Returns the see tags of the comment. - * - * @return an array of SeeTag representing the - * see tags of the comment. - */ - public SeeTag[] seeTags() { - return getComment() != null - ? getComment().seeTags() - : new SeeTag[0]; - } - - /** - * Returns all tags of the comment. - * - * @return an array of Tag representing all - * tags of the comment. - */ - public Tag[] tags() { - return getComment() != null - ? getComment().tags() - : new Tag[0]; - } - - /** - * Returns all tags of the comment whose name equals - * tagname. - * - * @return an array of Tag representing all tags of the - * comment whose name equals tagname. - */ - public Tag[] tags(String tagname) { - return getComment() != null - ? getComment().tags(tagname) - : new Tag[0]; - } - - /** - * Returns the commext text for non-null comments, - * otherwise the empty String. - * - * @return non-null comment text. - */ - public String commentText() { - return getComment() != null - ? getComment().commentText() - : ""; - } - - /** - * Sets isIncluded. - * - * @param isIncluded the new value of isIncluded. - */ - public void setIncluded(boolean isIncluded) { - this.isIncluded = isIncluded; - } - - /** - * Returns false by default. - * - * @return false by default. - */ - public boolean isClass() { - return false; - } - - /** - * Returns false by default. - * - * @return false by default. - */ - public boolean isConstructor() { - return false; - } - - /** - * Returns false by default. - * - * @return false by default. - */ - public boolean isError() { - return false; - } - - /** - * Returns false by default. - * - * @return false by default. - */ - public boolean isException() { - return false; - } - /** - * Returns false by default. - * - * @return by default./ - */ - public boolean isField() { - return false; - } - /** - * Returns isIncluded by default. - * - * @return by default./ - */ - public boolean isIncluded() { - return isIncluded; - } - - /** - * Returns false by default. - * - * @return by default./ - */ - public boolean isInterface() { - return false; - } - - /** - * Returns false by default. - * - * @return by default./ - */ - public boolean isMethod() { - return false; - } - - /** - * Returns false by default. - * - * @return by default./ - */ - public boolean isOrdinaryClass() { - return false; - } - - /** - * Returns false by default. - * - * @return by default./ - */ - public boolean isPointcut() { - return false; - } - - /** - * Returns false by default. - * - * @return by default./ - */ - public boolean isAdvice() { - return false; - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/DocletProxy.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/DocletProxy.java deleted file mode 100644 index 9fea74106..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/DocletProxy.java +++ /dev/null @@ -1,145 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ - -package org.aspectj.tools.ajdoc; -import org.aspectj.tools.doclets.standard.AbstractStandard; -import org.aspectj.tools.doclets.standard.Standard; - -import com.sun.javadoc.DocErrorReporter; -import com.sun.javadoc.RootDoc; - -import java.io.IOException; -import java.util.List; - -/** - */ -public interface DocletProxy { - public static final DocletProxy STANDARD - = JavadocStandardProxy.SINGLETON; - public static final DocletProxy DEFAULT - = StandardProxy.SINGLETON; - public int optionLength(String arg); - public boolean start(RootDoc root) - throws IOException; - public boolean validOptions(List options, DocErrorReporter handler) - throws IOException; -} - -/** - * This proxy delegates to Standard singleton, - * but delays alerts about it being unavailable until first use - */ -class StandardProxy implements DocletProxy { - public static final DocletProxy SINGLETON = new StandardProxy(); - private StandardProxy() { } - - /** check and delegate to standard */ - public int optionLength(String arg) { - return Standard.optionLength(arg); - } - /** check and delegate to standard */ - public boolean validOptions(List options, DocErrorReporter handler) - throws IOException { - return AbstractStandard.validOptions(docletOptions(options), handler); - } - // todo: validate that this is the expected format for doclet options - protected String[][] docletOptions(List options) { - if ((null == options) || (1 > options.size())) { - return new String[][]{}; - } - Object[] ra = options.toArray(); - String[] strs = new String[ra.length]; - for (int i = 0; i < ra.length; i++) { - strs[i] = (null == ra[i] ? null : ra[i].toString()); - } - return new String[][] {strs}; - } - - /** check and delegate to standard */ - public boolean start(RootDoc root) throws IOException { - return Standard.start(root); - } -} // StandardProxy - -/** - * This proxy delegates to javadoc Standard singleton. - */ -class JavadocStandardProxy implements DocletProxy { - public static final DocletProxy SINGLETON = new JavadocStandardProxy(); - private JavadocStandardProxy() { } - - /** check and delegate to standard */ - public int optionLength(String arg) { - return com.sun.tools.doclets.standard.Standard.optionLength(arg); - } - /** check and delegate to standard */ - public boolean validOptions(List options, DocErrorReporter handler) - throws IOException { - return com.sun.tools.doclets.standard.Standard.validOptions(docletOptions(options), handler); - } - // todo: validate that this is the expected format for doclet options - protected String[][] docletOptions(List options) { - if ((null == options) || (1 > options.size())) { - return new String[][]{}; - } - Object[] ra = options.toArray(); - String[] strs = new String[ra.length]; - for (int i = 0; i < ra.length; i++) { - strs[i] = (null == ra[i] ? null : ra[i].toString()); - } - return new String[][] {strs}; - } - - /** check and delegate to standard */ - public boolean start(RootDoc root) throws IOException { - return com.sun.tools.doclets.standard.Standard.start(root); - } -} // JavadocStandardProxy - -/** Wrap a Throwable as a RuntimeException - * This will render stack trace as the delegate stack trace, - * notwithstanding any call to fillInStackTrace. -class ExceptionWrapper extends RuntimeException { - Throwable delegate; - public ExceptionWrapper(Throwable t) { - delegate = (null == t ? new Error("null") : t); - } - public void printStackTrace() { - delegate.printStackTrace(); - } - public void printStackTrace(PrintStream stream) { - delegate.printStackTrace(stream); - } - public void printStackTrace(PrintWriter stream) { - delegate.printStackTrace(stream); - } - public String getMessage() { - return delegate.getMessage(); - } - public String getLocalizedMessage() { - return delegate.getLocalizedMessage(); - } - public Throwable fillInStackTrace() { - return delegate.fillInStackTrace(); - } -} -*/ diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/ErrPrinter.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/ErrPrinter.java deleted file mode 100644 index 96d2e7b0d..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/ErrPrinter.java +++ /dev/null @@ -1,627 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.ajdoc; - -import org.aspectj.compiler.base.ErrorHandler; -import org.aspectj.compiler.base.InternalCompilerError; - -import com.sun.javadoc.DocErrorReporter; - -import java.io.PrintWriter; -import java.lang.reflect.InvocationTargetException; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.List; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -/** - * A class to handler errors in ajdoc. - * - * @author Jeff Palm - */ -public class ErrPrinter - extends ErrorHandler - implements DocErrorReporter -{ - - /** The global instance that anyone can use. */ - public final static ErrPrinter instance = new ErrPrinter(); - - private String programName; - private PrintWriter out; - private PrintWriter err; - private ResourceBundle bundle; - private List keys = new ArrayList(); - private List msgs = new ArrayList(); - - static int cnt = 0; - - /** - * Construct with program name programName - * and printstreams err and out. - * - * @param programName program name. - * @param err error stream. - * @param out output stream. - */ - public ErrPrinter(String programName, - PrintWriter err, - PrintWriter out) { - super(err); - this.programName = programName; - this.err = err; - this.out = out; - try { - bundle = ResourceBundle.getBundle - ("org.aspectj.tools.ajdoc.resources.ajdoc"); - } catch (MissingResourceException e) { - throw new Error("Can't find ajdoc.properties: " + e); - } - } - - /** - * Construct with program name programName - * and printstreams System.err and System.out - * - * @param programName program name. - */ - public ErrPrinter(String programName) { - this(programName, - new PrintWriter(System.err, true), - new PrintWriter(System.out, true)); - } - - /** - * Construct with program name "ajdoc" - * and printstreams System.err and System.out - */ - public ErrPrinter() { - this("ajdoc"); - } - - /** - * Print error and increment the error count. - * - * @param error error message to print. - */ - public void printError(String error) { - errors++; - err.println(error); - err.flush(); - } - - /** - * Print warning and increment the warning count. - * - * @param warning warning message to print. - */ - public void printWarning(String warning) { - warnings++; - err.println(warning); - err.flush(); - } - - /** - * Print notice. - * - * @param notice notice message to print. - */ - public void printNotice(String notice) { - out.println(notice); - out.flush(); - } - - /** - * Returns the number of errors. - * - * @return number of errors. - */ - public int getNumErrors() { - return errors; - } - - /** - * Returns the number of warnings. - * - * @return number of warnings. - */ - public int getNumWarnings() { - return warnings; - } - - /** - * Returns the keys in the resource bundle. - * - * @return keys in the resource bundle. - */ - public List getKeys() { - return new ArrayList(keys); - } - - /** - * Returns the messages in the resource bundle. - * - * @return messages in the resource bundle. - */ - public List getMsgs() { - return new ArrayList(msgs); - } - - /** - * Handles InvocationTargetExceptions. - * - * @param e the exception. - * @param classname the class on which the method was trying - * to be invoked. - * @param methodName the name of the method trying to be invoked. - * @return the exception. - */ - public synchronized Throwable invocationTargetException - (InvocationTargetException e, - String classname, - String methodName) { - Throwable t = e.getTargetException(); - if (t != null) { - if (t instanceof OutOfMemoryError) { - error("out_of_memory"); - } else { - error("exception_thrown", "", classname, methodName, t+""); - t.printStackTrace(); - } - } - return t != null ? t : e; - } - - /** - * Handles an internal error. - * - * @param key key of the message to use. - * @param t exception thrown. - */ - public synchronized void internalError(String key, Throwable t) { - internalError(key, "", t); - } - - /** - * Handles an internal error. - * - * @param key key of the message to use. - * @param s0 first argument in the message. - * @param t exception thrown. - */ - public synchronized void internalError(String key, String s0, Throwable t) { - if (t instanceof InternalCompilerError) { - t = ((InternalCompilerError)t).uncaughtThrowable; - } - error(key, s0, t != null ? t.getMessage() : ""); - if (t != null) t.printStackTrace(); - internalError(t, null); - } - - - /** - * Prints an error message for key key - * ,and returns the number of errors. - * - * @param key key of the message. - * @return number of errors. - */ - public final int error(String key) { - printError(text(key)); - return errors; - } - - /** - * Prints an error message for key key - * and argument s0, - * and returns the number of errors. - * - * @param key key of the message. - * @param s0 argument to message. - * @return number of errors. - */ - public final int error(String key, String s0) { - printError(text(key,s0)); - return errors; - } - - /** - * Prints an error message for key key - * and arguments s0,s1, - * and returns the number of errors. - * - * @param key key of the message. - * @param s0 argument to message. - * @param s1 argument to message. - * @return number of errors. - */ - public final int error(String key, String s0, String s1) { - printError(text(key,s0,s1)); - return errors; - } - - /** - * Prints an error message for key key - * and arguments s0,s1,s2, - * and returns the number of errors. - * - * @param key key of the message. - * @param s0 argument to message. - * @param s1 argument to message. - * @param s2 argument to message. - * @return number of errors. - */ - public final int error(String key, String s0, String s1, - String s2) { - printError(text(key,s0,s1,s2)); - return errors; - } - /** - * Prints an error message for key key - * and arguments s0,s1,s2,cookieMonster, - * and returns the number of errors. - * - * @param key key of the message. - * @param s0 argument to message. - * @param s1 argument to message. - * @param s2 argument to message. - * @param cookieMonster argument to message. - * @return number of errors. - */ - public final int error(String key, String s0, String s1, - String s2, String cookieMonster) { - printError(text(key,s0,s1,s2,cookieMonster)); - return errors; - } - - /** - * Handles the thrown exception t - * with message key key, and returns - * the number of errors. - * - * @param t thrown exception. - * @param key message key. - * @return number of errors. - */ - public final int ex(Throwable t, String key) { - error(key); - if (t != null) t.printStackTrace(); - return errors; - } - - /** - * Handles the thrown exception t - * with message key key and - * argument s0, and returns - * the number of errors. - * - * @param t thrown exception. - * @param key message key. - * @param s0 argument to message. - * @return number of errors. - */ - public final int ex(Throwable t, String key, String s0) { - error(key,s0); - if (t != null) t.printStackTrace(); - return errors; - } - - /** - * Handles the thrown exception t - * with message key key and - * arguments s0,s1, and returns - * the number of errors. - * - * @param t thrown exception. - * @param key message key. - * @param s0 argument to message. - * @param s1 argument to message. - * @return number of errors. - */ - public final int ex(Throwable t, String key, String s0, String s1) { - error(key,s0,s1); - if (t != null) t.printStackTrace(); - return errors; - } - - /** - * Handles the thrown exception t - * with message key key and - * arguments s0,s1,s2, and returns - * the number of errors. - * - * @param t thrown exception. - * @param key message key. - * @param s0 argument to message. - * @param s1 argument to message. - * @param s2 argument to message. - * @return number of errors. - */ - public final int ex(Throwable t, String key, String s0, String s1, - String s2) { - error(key,s0,s1,s2); - if (t != null) t.printStackTrace(); - return errors; - } - - /** - * Handles the thrown exception t - * with message key key and - * arguments s0,s1,s2,snuffulufugus, and returns - * the number of errors. - * - * @param t thrown exception. - * @param key message key. - * @param s0 argument to message. - * @param s1 argument to message. - * @param s2 argument to message. - * @param snuffulufugus argument to message. - * @return number of errors. - */ - public final int ex(Throwable t, String key, String s0, String s1, - String s2, String snuffulufugus) { - error(key,s0,s1,s2,snuffulufugus); - if (t != null) t.printStackTrace(); - return errors; - } - - /** - * Prints the warning with key key - * and returns the number of warnings. - * - * @param key message key. - * @return number of warnings. - */ - public final int warning(String key) { - printWarning(text(key)); - return warnings; - } - - /** - * Prints the warning with key key and - * argument s0, - * and returns the number of warnings. - * - * @param key message key. - * @param s0 argument to message. - * @return number of warnings. - */ - public final int warning(String key, String s0) { - printWarning(text(key,s0)); - return warnings; - } - - /** - * Prints the warning with key key and - * arguments s0,s1, - * and returns the number of warnings. - * - * @param key message key. - * @param s0 argument to message. - * @param s1 argument to message. - * @return number of warnings. - */ - public final int warning(String key, String s0, String s1) { - printWarning(text(key,s0,s1)); - return warnings; - } - - /** - * Prints the warning with key key and - * arguments s0,s1,s2, - * and returns the number of warnings. - * - * @param key message key. - * @param s0 argument to message. - * @param s1 argument to message. - * @param s2 argument to message. - * @return number of warnings. - */ - public final int warning(String key, String s0, String s1, - String s2) { - printWarning(text(key,s0,s1,s2)); - return warnings; - } - - /** - * Prints the warning with key key and - * arguments s0,s1,s2,josefStalin, - * and returns the number of warnings. - * - * @param key message key. - * @param s0 argument to message. - * @param s1 argument to message. - * @param s2 argument to message. - * @param josefStalin argument to message. - * @return number of warnings. - */ - public final int warning(String key, String s0, String s1, - String s2, String josefStalin) { - printWarning(text(key,s0,s1,s2,josefStalin)); - return warnings; - } - - /** - * Print a notice with message key key. - * - * @param key message key. - */ - public final void notice(String key) { - printNotice(text(key)); - } - - /** - * Print a notice with message key key - * and argument s0. - * - * @param key message key. - * @param s0 argument to message. - */ - public final void notice(String key, String s0) { - printNotice(text(key,s0)); - } - - /** - * Print a notice with message key key - * and arguments s0,s1. - * - * @param key message key. - * @param s0 argument to message. - * @param s1 argument to message. - */ - public final void notice(String key, String s0, String s1) { - printNotice(text(key,s0,s1)); - } - - /** - * Print a notice with message key key - * and arguments s0,s1,s2. - * - * @param key message key. - * @param s0 argument to message. - * @param s1 argument to message. - * @param s2 argument to message. - */ - public final void notice(String key, String s0, String s1, - String s2) { - printNotice(text(key,s0,s1,s2)); - } - - /** - * Print a notice with message key key - * and arguments s0,s1,s2,bigbird. - * - * @param key message key. - * @param s0 argument to message. - * @param s1 argument to message. - * @param s2 argument to message. - * @param bigbird argument to message. - */ - public final void notice(String key, String s0, String s1, - String s2, String bigbird) { - printNotice(text(key,s0,s1,s2,bigbird)); - } - - /** - * Returns the String for message key key. - * - * @return String for message - * key key. - */ - protected final String text(String key) { - return text(key, ""); - } - - /** - * Returns the String for message key key - * and argument s0 - * - * @param s0 argument to message. - * @return String for message - * key key. - */ - protected final String text(String key, String s0) { - return text(key, s0, ""); - } - - /** - * Returns the String for message key key - * and arguments s0,s1 - * - * @param s0 argument to message. - * @param s1 argument to message. - * @return String for message - * key key. - */ - protected final String text(String key, String s0, String s1) { - return text(key, s0, s1, ""); - } - - /** - * Returns the String for message key key - * and arguments s0,s1,s2 - * - * @param s0 argument to message. - * @param s1 argument to message. - * @param s2 argument to message. - * @return String for message - * key key. - */ - protected final String text(String key, String s0, String s1, - String s2) { - return text(key, s0, s1, s2, ""); - } - - /** - * Returns the String for message key key - * and arguments s0,s1,s2,oscarTheGrouch - * - * @param s0 argument to message. - * @param s1 argument to message. - * @param s2 argument to message. - * @param oscarTheGrouch argument to message. - * @return String for message - * key key. - */ - protected final String text(String key, String s0, String s1, - String s2, String oscarTheGrouch) { - return text(key, new String[]{s0,s1,s2,oscarTheGrouch}); - } - - /** - * Returns the String for the message key key - * with arguments contained in args. - * - * @param key message key. - * @param args array of arguments to substitute. - * @return String for message with key - * key and arguments - * args - */ - protected final String text(String key, String[] args) { - String msg = MessageFormat.format(string(key), args); - msgs.add(msg); - return msg; - } - - /** - * Returns the String with message key. - * - * @param key message key. - * @return String for message with key key. - */ - protected final String string(String key) { - keys.add(key); - try { - return bundle.getString(key); - } catch (MissingResourceException e) { - throw new Error("Can't find " + key + " in " + bundle); - } - } - PrintWriter getErr() { - return err; - } - PrintWriter getOut() { - return out; - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/ExecutableMemberDocImpl.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/ExecutableMemberDocImpl.java deleted file mode 100644 index 807ef080d..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/ExecutableMemberDocImpl.java +++ /dev/null @@ -1,307 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.ajdoc; - -import org.aspectj.ajdoc.AdviceDoc; -import org.aspectj.compiler.base.ast.Formals; -import org.aspectj.compiler.base.ast.NameType; -import org.aspectj.compiler.base.ast.TypeDs; - -import com.sun.javadoc.ClassDoc; -import com.sun.javadoc.ExecutableMemberDoc; -import com.sun.javadoc.ParamTag; -import com.sun.javadoc.Parameter; -import com.sun.javadoc.ThrowsTag; - -import java.lang.reflect.Modifier; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -public abstract class ExecutableMemberDocImpl - extends MemberDocImpl - implements ExecutableMemberDoc { - - /* - * These three fields should be final, but can't because - * they contain calls to abstract methods that aren't - * valid until after the subclasses constructor is run. - * To compensate the accessor methods lazily evaluate - * them, and these methods are final. - */ - - /** The collection of advice placed on each ExecutableMemberDoc. */ - private Collection advice; - - /** The List of parameters. */ - private Collection parameters; - - /** The List of thrown exceptions. */ - private Collection thrownExceptions; - - /** The full signature. */ - private String signature; - - /** The flat signature. */ - private String flatSignature; - - /** - * Constructs a new Doc with the enclosing ClassDoc. - * - * @param containingClass enclosing ClassDoc. - */ - public ExecutableMemberDocImpl(ClassDoc containingClass) { - super(containingClass); - } - - /** - * Returns a non-null Collection of AdviceDoc - * representing the advice placed on the underlying Dec. - * - * @return a non-null Collection of AdviceDoc - * representing the advice placed on the - * underlying Dec. - */ - protected abstract Collection createAdvice(); - - /** - * Returns the Formals of the underlying Dec. - * - * @return the Formals of the underlying Dec. - */ - protected abstract Formals getFormals(); - - /** - * Returns the TypeDs representing the exceptions - * thrown by the underlying Dec. - * - * @return the TypeDs representing the exceptions - * thrown by the underlying Dec. - */ - protected abstract TypeDs getThrows(); - - - /** - * Converts the passed in Formals to a Collection of - * Parameter and sets our parameters to this value. - * - * @param formals the Formals to use. - */ - public void makeParameters(Formals formals) { - parameters = createParameters(formals); - } - - /** - * Converts the passed in TypeDs to a Collection of - * ClassDoc and sets our thrownExceptions to this value. - * - * @param thrown the TypeDs to use. - */ - public void makeThrownExceptions(TypeDs thrown) { - thrownExceptions = createThrownExceptions(thrown); - } - - /** - * Returns the advice affecting this member. - * - * @return an array of AdviceDoc representing the advice - * affecting this member. - */ - public final AdviceDoc[] advice() { - if (advice == null) advice = createAdvice(); - return (AdviceDoc[])advice.toArray(new AdviceDoc[advice.size()]); - } - - /** - * Returns the exceptions this code declares to throw. - * - * @return an array of ClassDoc representing the exceptions - * this code declares to throw. - */ - public final ClassDoc[] thrownExceptions() { - if (thrownExceptions == null) makeThrownExceptions(getThrows()); - return (ClassDoc[])thrownExceptions.toArray - (new ClassDoc[thrownExceptions.size()]); - } - - /** - * Returns the parameters taken by this code. - * - * @return an array of Parameter representing the - * parameters this code takes. - */ - public final Parameter[] parameters() { - if (parameters == null) makeParameters(getFormals()); - return (Parameter[])parameters.toArray - (new Parameter[parameters.size()]); - } - - /** - * Returns the flat signature. - * - * @return the flat signature with all types unqualified. - */ - public String flatSignature() { - if (flatSignature == null) { - flatSignature = Util.flatSignature(parameters()); - } - return flatSignature; - } - - /** - * Returns the full signature. - * - * @return the full signature with all types qualified. - */ - public String signature() { - if (signature == null) { - signature = Util.signature(parameters()); - } - return signature; - } - - /** - * Returns true if this code is synchronized. - * - * @return true if this code is synchronized. - */ - public boolean isSynchronized() { - //return getModifiers().isSynchronized(); - return Modifier.isSynchronized(modifierSpecifier()); - } - - /** - * Returns trueif this code is native. - * - * @return trueif this code is native. - */ - public boolean isNative() { - //return (modifierSpecifier() & Modifiers.NATIVE) != 0; - return Modifier.isNative(modifierSpecifier()); - } - - /** - * Returns the throw tags describing exceptions thrown - * declared by this code. - * - * @return an array of ThrowsTag representing the exception - * this code declares to throw. - */ - public ThrowsTag[] throwsTags() { - return getComment().throwsTags(); - } - - /** - * Returns the param tags describing parameters taken - * by this code. - * - * @return an array of ParamTag representing the - * parameters taken by this code. - */ - public ParamTag[] paramTags() { - return getComment().paramTags(); - } - - /** - * Returns the simple name followed the parameters - * enclosed in parens. - * - * @return the simple name followed the parameters - * enclosed in parens. - */ - public String toString() { - StringBuffer sb = new StringBuffer(name()); - sb.append('('); - Parameter[] params = parameters(); - for (int i = 0, N = params.length; i < N; i++) { - if (i > 0) sb.append(","); - sb.append(params[i].type().qualifiedTypeName()); - sb.append(params[i].type().dimension()); - } - sb.append(')'); - return sb.toString(); - } - - /** - * Returns a Collection of Parameter corresponding to - * the Formals passed in. - * - * @param formals the Formals to use. - * @return a Collection of Parameter corresponding to - * the Formals passed in. - */ - private Collection createParameters(Formals formals) { - if (formals == null) return Collections.EMPTY_LIST; - List list = new ArrayList(formals.size()); - for (int i = 0, N = formals.size(); i < N; i++) { - list.add(new ParameterImpl(formals.get(i))); - } - return list; - } - - /** - * Returns a Collection of ClassDoc corresponding to - * the TypeDs passed in. - * - * @param thrown the TypeDs to use - * @return a Collection of ClassDoc corresponding to - * the TypeDs passed in. - */ - private Collection createThrownExceptions(TypeDs typeds) { - if (typeds == null) return Collections.EMPTY_LIST; - List list = new ArrayList(typeds.size()); - for (int i = 0, N = typeds.size(); i < N; i++) { - list.add(ClassDocImpl.getInstance - (((NameType)typeds.get(i).getType()).getTypeDec())); - } - return list; - } - - /** - * Returns true if the passed in Object is - * an ExecutableMemberDocImpl, its name equals ours, and - * its parameters equals ours. - * - * @return equality based on name and parameters. - */ - public boolean weakEquals(Object md) { - if (!(md instanceof ExecutableMemberDocImpl)) { - return false; - } - ExecutableMemberDocImpl emdi = (ExecutableMemberDocImpl)md; - if (!name().equals(emdi.name())) { - return false; - } - Parameter[] ourPds = this.parameters(); - Parameter[] edsPds = emdi.parameters(); - if (ourPds.length != edsPds.length) { - return false; - } - for (int i = 0, N = ourPds.length; i < N; i++) { - if (!ourPds[i].equals(edsPds[i])) { - return false; - } - } - return true; - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/FieldDocImpl.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/FieldDocImpl.java deleted file mode 100644 index 2f0ca4c9a..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/FieldDocImpl.java +++ /dev/null @@ -1,140 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.ajdoc; - -import org.aspectj.compiler.base.ast.Dec; -import org.aspectj.compiler.base.ast.FieldDec; - -import com.sun.javadoc.ClassDoc; -import com.sun.javadoc.SerialFieldTag; - -import java.lang.reflect.Modifier; - -public class FieldDocImpl - extends MemberDocImpl - implements org.aspectj.ajdoc.FieldDoc { - - /** The FieldDec that corresponds to this FieldDoc. */ - private final FieldDec field; - - /** - * The type of this field. This can't be set initially - * because the compiler doesn't resolve the types for - * introductions, yet, so we have to allow others to set it. - */ - private org.aspectj.compiler.base.ast.Type type; - - /** - * Sets the org.apectj.compiler.base.ast.Type used to return - * the com.sun.javadoc.Type. - * - * @param type the new org.aspectj.compiler.base.ast.Type used - * to find the com.sun.javadoc.Type. - * @hack This is only needed because of unresolved - * introduced fields. - */ - public void setType(org.aspectj.compiler.base.ast.Type type) { - this.type = type; - } - - public FieldDocImpl(ClassDoc containingClass, FieldDec field) { - super(containingClass); - this.field = field; - setType(field.getType()); - } - - protected Dec dec() { - return field; - } - - - protected FieldDec fieldDec() { - return field; - } - - /** - * Returns true. - * - * @return true. - */ - public boolean isField() { - return true; - } - - /** - * Returns the type of this field. - * - * @return the type of this field. - */ - public com.sun.javadoc.Type type() { - return TypeImpl.getInstance(type); - } - - /** - * Return true is this field is volatile. - * - * @return true is this field is volatile. - */ - public boolean isVolatile() { - return Modifier.isVolatile(modifierSpecifier()); - } - - /** - * Return true is this field is transient. - * - * @return true is this field is transient. - */ - public boolean isTransient() { - return Modifier.isTransient(modifierSpecifier()); - } - - /** - * Returns the serial field tags for this field. - * - * @return an array of SerialFieldTag representing the - * serial field tags for this field. - */ - public SerialFieldTag[] serialFieldTags() { - return getComment().serialFieldTags(); - } - - /** - * Returns the name of the field. - * - * @return the name of the field. - */ - public String toString() { - return name(); - } - - /** - * Returns true is md is a - * FieldDocImpl and has the same name. - * - * @return true is md is a - * FieldDocImpl and has the same name. - */ - public boolean weakEquals(Object md) { - if (!(md instanceof FieldDocImpl)) return false; - return name().equals(((FieldDocImpl)md).name()); - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/FilteredDecList.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/FilteredDecList.java deleted file mode 100644 index df137add2..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/FilteredDecList.java +++ /dev/null @@ -1,219 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.ajdoc; - -import org.aspectj.compiler.base.ast.ConstructorDec; -import org.aspectj.compiler.base.ast.Dec; -import org.aspectj.compiler.base.ast.FieldDec; -import org.aspectj.compiler.base.ast.MethodDec; -import org.aspectj.compiler.base.ast.Type; -import org.aspectj.compiler.base.ast.TypeDec; -import org.aspectj.compiler.crosscuts.ast.PointcutDec; - -import java.util.ArrayList; - -/** -* Factory collection with Type-specific "add" methods which -* checks if ..Dec should be included and if so constructs and adds. -* A Dec should be included if AccessChecker.canAccess({Dec variants}) -* and the type is the same (if type is specified). -* This consolidates construction of DocImpl for classes and class members. -*/ -public class FilteredDecList extends ArrayList { - final protected AccessChecker filter ; - final protected ClassDocImpl classDocImpl ; - final protected Type declaringType ; - - /** - * Create a declaration list enforced by a filter and - * optionally a ClassDocImpl. If the ClassDocImpl is not null, - * then you cannot add members outside its type; if it is null, - * attempting to add members has undefined results. (You may - * still create ClassDoc.) - * @param filter the AccessChecker used to test for inclusion - * (use AccessChecker.PUBLIC if null) - * @param type the classDocImpl used to construct added members - * and ensure they are declared in this type - * (ignore test if null) - */ - FilteredDecList(AccessChecker filter, ClassDocImpl classDocImpl) { - this.filter = (null != filter ? filter - : AccessChecker.PUBLIC); - this.classDocImpl = classDocImpl; - TypeDec td = (null == classDocImpl? null - : classDocImpl.typeDec()); - this.declaringType = (null == td? null : td.getType()); - } - - /** - * Check for match with our type (if set) - * @param dec the Dec to get the incoming declaring type from - * @return true unless our type is set and does not equals dec declaring type - */ - protected final boolean sameType(Dec dec) { - Type other = (null == dec ? null : dec.getDeclaringType()); - boolean result = ((null != dec) - && ((declaringType == null) - || declaringType.equals(other))) ; - /* - System.err.println("sameType("+dec+") " + declaringType - + " ?= " + other); - if (!result) { - System.err.println("false FilteredDecList.sameType(" + dec - + ") us " + declaringType); - } - */ - return result; - } - - /** - * Implements policy on incoming TypeDec. - * @param dec the TypeDec to check - * @throws IllegalArgumentException if null == dec - */ - protected void checkDec(Dec dec) { - if (null == dec) throw new IllegalArgumentException("null dec"); - } - - /** - * Construct and add inner class from dec - * if outer is included and dec should be included. - * @param outer the ClassDocImpl which encloses this dec - * @param dec the TypeDec for the inner class to add to this list, enclosed by outer - * @return false if dec is null or true if added - * @throws IllegalArgumentException if outer is null or dec is null - */ - public boolean add(ClassDocImpl outer, TypeDec dec) { - checkDec(dec); - if (null == outer) throw new IllegalArgumentException("null outer"); - if ((filter.canAccess(outer.typeDec()) && filter.canAccess(dec))) { - ClassDocImpl doc = ClassDocImpl.getInstance(outer, dec); - if (null != doc) { - doc.setIncluded(true); - return add((Object) doc); - } - } - denied(outer, dec); - return false; - } - - /** - * Add ClassDocImpl if dec should be included - * and ClassDocImpl.getInstance(..) returns something. - * Also sets the included property to true; - * @param dec the TypeDec for the class to add - * @return false if dec is null or true if added - * @throws IllegalArgumentException if outer is null or dec is null - */ - public boolean add(TypeDec dec) { - checkDec(dec); - if (filter.canAccess(dec)) { - ClassDocImpl doc = ClassDocImpl.getInstance(dec); - if (null != doc) { - doc.setIncluded(true); - return add((Object) doc); - } - } - denied(dec); - return false; - } - - /** - * Add MethodDocImpl to this list if dec should be included - * @param dec the MethodDoc for the method to add - * @return true if added - * @throws IllegalArgumentException if dec is null - */ - public boolean add(MethodDec dec) { - checkDec(dec); - if (sameType(dec) && filter.canAccess(dec)) { - return add((Object) new MethodDocImpl(classDocImpl, dec)); - } - denied(dec); - return false; - } - - /** - * Add ConstructorDocImpl to this list if dec should be included - * @param dec the ConstructorDoc for the constructor to add - * @return true if added - * @throws IllegalArgumentException if dec is null - */ - public boolean add(ConstructorDec dec) { - checkDec(dec); - if (sameType(dec) && filter.canAccess(dec)) { - return add((Object) new ConstructorDocImpl(classDocImpl, dec)); - } - denied(dec); - return false; - } - - /** - * Add FieldDocImpl to this list if dec should be included - * @param dec the FieldDoc for the field to add - * @return true if added - * @throws IllegalArgumentException if dec is null - */ - public boolean add(FieldDec dec) { - checkDec(dec); - if (sameType(dec) && filter.canAccess(dec)) { - return add((Object) new FieldDocImpl(classDocImpl, dec)); - } - denied(dec); - return false; - } - - /** - * Add PointcutDocImpl to this list if dec should be included - * @param dec the PointcutDoc for the pointcut to add - * @return true if added - * @throws IllegalArgumentException if dec is null - */ - public boolean add(PointcutDec dec) { - checkDec(dec); - if (sameType(dec) && filter.canAccess(dec)) { - return add((Object) new PointcutDocImpl(classDocImpl, dec)); - } - denied(dec); - return false; - } - - /** - * Called when some dec and outer is denied addition. - * Currently does nothing. - * @param outer the ClassDocImpl which encloses this dec - * @param dec the TypeDec for the inner class to add to this list, enclosed by outer - */ - protected void denied(ClassDocImpl outer, TypeDec dec) { - // System.err.println(this + " denied " + o + " with " + p); - } - - /** - * signalled when some dec is denied addition. - * Currently does nothing. - * @param dec the Dec denied addition - */ - protected void denied(Dec dec) { - // System.err.println(this + " denied " + o); - } -} // class FilteredDecList - diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/IntroducedDocImpl.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/IntroducedDocImpl.java deleted file mode 100644 index f49669764..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/IntroducedDocImpl.java +++ /dev/null @@ -1,169 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.ajdoc; - -import org.aspectj.ajdoc.ClassDoc; -import org.aspectj.ajdoc.IntroducedDoc; -import org.aspectj.ajdoc.MemberDoc; -import org.aspectj.compiler.base.ast.ConstructorDec; -import org.aspectj.compiler.base.ast.Dec; -import org.aspectj.compiler.base.ast.FieldDec; -import org.aspectj.compiler.base.ast.MethodDec; -import org.aspectj.compiler.base.ast.TypeDec; -import org.aspectj.compiler.crosscuts.ast.GenTypeName; -import org.aspectj.compiler.crosscuts.ast.IntroducedDec; - -import java.util.Iterator; -import java.util.Set; - -public class IntroducedDocImpl extends IntroductionDocImpl implements IntroducedDoc { - - /** The introduction to which we delegate. */ - private final IntroducedDec introducedDec; - - /** The member this introduction introduced. */ - private final MemberDocImpl member; - - public IntroducedDocImpl(com.sun.javadoc.ClassDoc containingClass, - IntroducedDec introducedDec) { - super(containingClass); - this.introducedDec = introducedDec; // used by findMember - (member = findMember()).setIntroduced(this); - createTargets(); - } - - protected Dec dec() { - return introducedDec; - } - - protected void createTargets() { - /* - * HACK: - * Because the compiler doesn't resolve the types - * of introductions, yet, we have to set the introduced - * doc (member) with the appropriate fields, whether it's a - * - field - * - method - * - constructor - */ - Set affects = ajc().getCorrespondences().getAffects(introducedDec); - if (affects.size() < 1) return; - nextType: - for (Iterator it = affects.iterator(); it.hasNext();) { - Object o = it.next(); - if (o instanceof TypeDec) { - TypeDec owner = (TypeDec)o; - ClassDoc cd = ClassDocImpl.getInstance(owner); - com.sun.javadoc.FieldDoc[] fs = cd.fields(); - for (int i = 0; i < fs.length; i++) { - if (member.weakEquals(fs[i])) { // XXX weakEquals is unimplemented - ((FieldDocImpl)fs[i]).setIntroduced(this); - addTarget(cd); - ((FieldDocImpl)member).setType(((FieldDocImpl)fs[i]). - fieldDec().getType()); - // why fixup only fields? - continue nextType; - } - } - com.sun.javadoc.MethodDoc[] ms = cd.methods(); - for (int i = 0; i < ms.length; i++) { - if (member.weakEquals(ms[i])) { - ((MethodDocImpl)ms[i]).setIntroduced(this); - addTarget(cd); - ((MethodDocImpl)member).setType(((MethodDocImpl)ms[i]). - codeDec().getResultTypeD(). - getType()); - ((ExecutableMemberDocImpl)member). - makeParameters(((MethodDocImpl)ms[i]). - codeDec().getFormals()); - continue nextType; - } - } - com.sun.javadoc.ConstructorDoc[] cs = cd.constructors(); - for (int i = 0; i < cs.length; i++) { - if (member.weakEquals(cs[i])) { - ((ConstructorDocImpl)cs[i]).setIntroduced(this); - addTarget(cd); - ((ExecutableMemberDocImpl)member). - makeParameters(((ConstructorDocImpl)cs[i]). - codeDec().getFormals()); - continue nextType; - } - } - } - } - } - - public MemberDoc member() { - return member; - } - - /** - * Returns the name of the member introduction. - * - * @return the name. - */ - public String name() { // XXX unused? - Dec indec = introducedDec.getDec(); - if (indec != null) { - return "" + indec.getId(); // XXX - } else { - return ""; - } - } - - private MemberDocImpl findMember() { - Dec dec = introducedDec.getDec(); - // fix applied all, though bug was only in methods and constructors - // verified working in all, including fields - dec.setSourceLocation(introducedDec.getSourceLocation()); // PR790, 712 - //TODO: a little hacky now - if (dec instanceof FieldDec) { - return new FieldDocImpl(containingClass(), - (FieldDec)dec); - - } else if (dec instanceof ConstructorDec) { - return new ConstructorDocImpl(containingClass(), - (ConstructorDec)dec); - } else if (dec instanceof MethodDec) { - return new MethodDocImpl(containingClass(), - (MethodDec)dec); - } else { - return null; - } - // should print type pattern for type of introduced member, - // but it messes up source/target associations -// GenTypeName gtn = introducedDec.getTargets(); -// if (null != gtn) { -// name = gtn.toShortString() + name; -// } - } - - /** - * Returns the toString() of the member. - * - * @return the toString() of the member. - */ - public String toString() { - return member.toString(); - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/IntroducedSuperDocImpl.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/IntroducedSuperDocImpl.java deleted file mode 100644 index 52dd85175..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/IntroducedSuperDocImpl.java +++ /dev/null @@ -1,103 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.ajdoc; - -import org.aspectj.ajdoc.IntroducedSuperDoc; -import org.aspectj.compiler.base.ast.Dec; -import org.aspectj.compiler.base.ast.TypeDs; -import org.aspectj.compiler.crosscuts.ast.IntroducedSuperDec; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -public class IntroducedSuperDocImpl - extends IntroductionDocImpl - implements IntroducedSuperDoc { - - /** The introduction to which we delegate. */ - private final IntroducedSuperDec introducedSuperDec; - - /** The types we introduce onto our targets. */ - private final Collection types; - - public IntroducedSuperDocImpl(com.sun.javadoc.ClassDoc containingClass, - IntroducedSuperDec introducedSuperDec) { - super(containingClass); - this.introducedSuperDec = introducedSuperDec; - types = createTypes(); - } - - protected Dec dec() { - return introducedSuperDec; - } - - /** - * Returns true is this introduction - * places implements introductions on its - * targets. - * - * @return true is this introduction - * places implements introductions - * on its targets. - */ - public boolean isImplements() { - return introducedSuperDec.getIsImplements(); - } - - /** - * Returns the types that this introduction introduces - * into it's targets type hierarchy. - * - * @return an array of org.aspectj.ajdoc.Type representing - * the types this introduction has introducted onto - * its targets type hierarchy. - */ - public org.aspectj.ajdoc.Type[] types() { - return (org.aspectj.ajdoc.Type[])types.toArray - (new org.aspectj.ajdoc.Type[types.size()]); - } - - /** - * Returns the name of the type introduction. - * - * @return the name. - */ - public String name() { if (true) return ""; // XXX unimplemented - return (introducedSuperDec.getTypeDs().size() != 0) - ? ((org.aspectj.ajdoc.Type)introducedSuperDec.getTypeDs(). - get(0).getType()).typeName() - : ""; - //TODO: This could fuck us up!!! - } - - private final Collection createTypes() { - TypeDs typeds = introducedSuperDec.getTypeDs(); - if (typeds == null) return Collections.EMPTY_LIST; - List list = new ArrayList(); - for (int i = 0, N = typeds.size(); i < N; i++) { - list.add(ClassDocImpl.getInstance(typeds.get(i).getType().getTypeDec())); - } - return list; - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/IntroductionDocImpl.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/IntroductionDocImpl.java deleted file mode 100644 index 84be926dc..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/IntroductionDocImpl.java +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.ajdoc; - -import org.aspectj.ajdoc.AspectDoc; -import org.aspectj.ajdoc.ClassDoc; -import org.aspectj.ajdoc.IntroductionDoc; -import org.aspectj.compiler.crosscuts.ast.IntroducedDec; -import org.aspectj.compiler.crosscuts.ast.IntroducedSuperDec; - -import java.util.ArrayList; -import java.util.Collection; - -public abstract class IntroductionDocImpl - extends MemberDocImpl - implements IntroductionDoc { - - /** Creats a new instance of IntroductionDoc from o. */ - public static IntroductionDocImpl getInstance(AspectDoc ad, Object o) { - return factory.getInstance(ad, o); - } - - /** The factory in charge of creating instances of IntroductionDocImpl. */ - private final static Factory factory = new Factory(); - - private final Collection targets = new ArrayList(); - - public void addTarget(ClassDoc cd) { targets.add(cd); } - - protected IntroductionDocImpl(com.sun.javadoc.ClassDoc containingClass) { - super(containingClass); - } - - //protected abstract Collection createTargets(); - - /** - * Returns the classes that are affected by this introduction. - * - * @return an array of ClassDoc representing the classes - * affected by this introduction. - */ - public final ClassDoc[] targets() { - //if (targets == null) targets = createTargets(); - return (ClassDoc[])targets.toArray(new ClassDoc[targets.size()]); - } - - /** - * The class is in charge of creating - * instances of IntroductionDocImpl. - */ - private final static class Factory { - public static IntroductionDocImpl getInstance(AspectDoc ad, Object o) { - if (o instanceof IntroducedSuperDec) { - return new IntroducedSuperDocImpl(ad, (IntroducedSuperDec)o); - } - if (o instanceof IntroducedDec) { - return new IntroducedDocImpl(ad, (IntroducedDec)o); - } - return null; - } - } - - /** TODO */ - public boolean weakEquals(Object md) { - return false; // TODO - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/Main.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/Main.java deleted file mode 100644 index c640b5d68..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/Main.java +++ /dev/null @@ -1,112 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.ajdoc; - -/** - * Entry point for ajdoc. - * - * @author Jeff Palm - */ -public class Main { - /** - * value returned from execute(..) - * when the JDK tools are not supported - */ - public static final int PLATFORM_ERROR = 3; - - /** - * Call {@link #execute} and exit with - * its exit code. - * - * @param args Command line arguments. - */ - public static void main(String[] args) { - System.exit(execute(args)); - } - - /** - * Programmatic entry without calling System.exit, - * returning the result of {@link Ajdoc#execute(String[])}. - * - * @param args Command line arguments. - * @return PLATFORM_ERROR if platformErrorMessage() is not null - * or the result of calling {@link Ajdoc#execute(String[])}. - * @throw Error if bad platform - look at message - */ - public static int execute(String[] args) { - int result = 0; - String platformError = platformErrorMessage(); - if (null != platformError) { - result = PLATFORM_ERROR; - System.err.println(platformError); - } else { - Ajdoc me = new Ajdoc(); - result = me.execute(args); - } - return result; - } - - /** - * Generate version error message if we cannot run in this VM - * or using this class path. - * @return null if no error or String describing error otherwise - */ - public static String platformErrorMessage() { - // todo: stolen from ajc.Main - boolean failed = false; - final String[] versions = new String[] - { "java.lang.reflect.Proxy" // 1.3: failed if class not found - // permit users to run in 1.4 iff using 1.3 tools.jar - //, "java.lang.CharSequence" // 1.4: failed if class found - }; - for (int i = 0; i < versions.length; i++) { - try { - Class.forName(versions[i]); - failed = (i == 1); - } catch (ClassNotFoundException cnfe) { - failed = (i == 0); - } catch (Error err) { - failed = (i == 0); - } - if (failed) { - String version = "(unknown version)"; - try { version = System.getProperty("java.version"); } - catch (Throwable t) { } // ignore - return "Ajdoc requires J2SE 1.3; not java " + version; - } - } - // now looking for tools.jar - try { - Class.forName("com.sun.javadoc.RootDoc"); // may be version error - Class.forName("com.sun.javadoc.Type"); // not in 1.4 - } catch (ClassNotFoundException cnfe) { - // System.err.println(cnfe.getMessage()); - // cnfe.printStackTrace(System.err); // XXX - return "Requires tools.jar from J2SE 1.3 (not 1.2 or 1.4) be on the class path"; - } catch (Error err) { // probably wrong version of the class - // System.err.println(err.getMessage()); - // err.printStackTrace(System.err); // XXX - return "Requires tools.jar from J2SE 1.3 (not 1.2 or 1.4) be on the class path"; - } - return null; - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/MemberDocImpl.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/MemberDocImpl.java deleted file mode 100644 index 63e6fedd8..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/MemberDocImpl.java +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.ajdoc; - -import org.aspectj.ajdoc.IntroducedDoc; -import org.aspectj.ajdoc.MemberDoc; - -public abstract class MemberDocImpl - extends ProgramElementDocImpl - implements MemberDoc { - - /** - * The introduction that introduces this member - * to its enclosing type. - */ - private IntroducedDoc introduced; - - public MemberDocImpl(com.sun.javadoc.ClassDoc containingClass) { - super(containingClass); - } - - /** - * Returns whether the passed in Object is equals - * based on type names and the name - * of the declaration. - * - * @return true if the passed in Object - * is equal to this based on type names - * and field names. - */ - public abstract boolean weakEquals(Object other); - - /** - * Sets this member's introduction. - * - * @param introduced the new introduction. - */ - protected void setIntroduced(IntroducedDoc introduced) { - this.introduced = introduced; - } - - /** - * Returns the introduction that introduced this member onto - * its enclosing type -- this value may be null - * if the member wasn't introduced. - * - * @return an IntroducedDoc representing the introduction - * that introduced this member onto its enclosing - * type. The return value may be null. - */ - public IntroducedDoc introduced() { - return introduced; - } - - /** - * Returns trueif this code is synthetic. - * - * @return trueif this code is synthetic. - */ - public boolean isSynthetic() { - return (!dec().isLanguageVisible()); - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/MethodDocImpl.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/MethodDocImpl.java deleted file mode 100644 index ff1d85078..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/MethodDocImpl.java +++ /dev/null @@ -1,125 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.ajdoc; - -import org.aspectj.compiler.base.ast.MethodDec; -import org.aspectj.compiler.base.ast.NameType; -import org.aspectj.compiler.base.ast.TypeDec; - -import com.sun.javadoc.ClassDoc; - -import java.lang.reflect.Modifier; - -public class MethodDocImpl - extends CodeDocImpl - implements org.aspectj.ajdoc.MethodDoc { - - /* - * This is a hack because the compiler isn't resolving - * introduced types. - */ - private org.aspectj.compiler.base.ast.Type type; - public void setType(org.aspectj.compiler.base.ast.Type type) { - this.type = type; - } - - public MethodDocImpl(ClassDoc containingClass, MethodDec methodDec) { - super(containingClass, methodDec); - setType(codeDec().getResultTypeD().getType()); - } - - protected MethodDec methodDec() { - return (MethodDec)codeDec(); - } - - /** - * Returns true. - * - * @return true. - */ - public boolean isMethod() { - return true; - } - - /** - * Returns true if this method is abstract. - * - * @return true if this method is abstract. - */ - public boolean isAbstract() { - return methodDec().isAbstract(); - } - - /** - * Returns the return type of this method. - * - * @return the Type representing the type this - * method returns. - */ - public com.sun.javadoc.Type returnType() { - return TypeImpl.getInstance(type); - //return null; //TODO getResultTypeD().getType(); - } - - /** - * Returns the type that nearest super class that defines - * this method. - * - * @return the type that nearest super class that defines - * this method. - */ - public ClassDoc overriddenClass() { - //Exprs params = getFormals().makeExprs(); // do this for side-effect?XXX - TypeDec where = methodDec().getDeclaringType().getTypeDec(); - NameType superType = (NameType)where.getSuperClassType(); - while (superType != null) { - MethodDec method = Util.methodDec(superType, - methodDec().getId(), - methodDec().getFormals()); - if (method != null && !method.getId().equals("not$found")) { - if (method.getDeclaringType().equals(superType)) { - return null; - } - } - if (superType.getTypeDec().getFullName(). - equals("java.lang.Object")) { - return null; - } - superType = (NameType)superType.getTypeDec().getSuperClassType(); - } - return null; - } - - /** - * Returns the int modifiers for this method. - * - * @return the int modifiers for this method. - * @see java.lang.reflect.Modifier - */ - public int modifierSpecifier() { - //XXX interface methods have the ABSTRACT bit set - if (containingClass().isInterface()) { - return super.modifierSpecifier() & ~Modifier.ABSTRACT; - } - return super.modifierSpecifier(); - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/OfClauseDocImpl.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/OfClauseDocImpl.java deleted file mode 100644 index b7889344f..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/OfClauseDocImpl.java +++ /dev/null @@ -1,95 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.ajdoc; - -import org.aspectj.ajdoc.ClassDoc; -import org.aspectj.ajdoc.OfClauseDoc; -import org.aspectj.ajdoc.OfEachObjectDoc; -import org.aspectj.compiler.crosscuts.ast.Pcd; -import org.aspectj.compiler.crosscuts.ast.PerCFlow; -import org.aspectj.compiler.crosscuts.ast.PerClause; -import org.aspectj.compiler.crosscuts.ast.PerObject; -import org.aspectj.compiler.crosscuts.ast.PerSingleton; - -import java.util.Collections; -import java.util.List; - -public class OfClauseDocImpl { - - /** TODO */ - public final static OfClauseDoc getInstance(PerClause clause) { - return factory.getInstance(clause); - } - - /** The factory used to create the instance. */ - private final static Factory factory = new Factory(); - - /** TODO */ - private final static class OfEachObjectDocImpl implements OfEachObjectDoc { - private final List instances; - private OfEachObjectDocImpl(PerObject eo) { - instances = createInstances(eo); - } - public ClassDoc[] instances() { - return (ClassDoc[])instances.toArray(new ClassDoc[instances.size()]); - } - public OfEachObjectDoc.Kind kind() { - return OfClauseDoc.Kind.EACH_OBJECT; - } - private List createInstances(PerObject eo) { - Pcd pc = eo.getPcd(); - if (pc == null) { - return Collections.EMPTY_LIST; - } - return Collections.EMPTY_LIST; - } - } - - /** TODO */ - private static class Factory { - - private final static OfClauseDoc EACH_CFLOW = new OfClauseDoc(){ - public OfClauseDoc.Kind kind() { - return OfClauseDoc.Kind.EACH_CFLOW; - } - }; - - private final static OfClauseDoc EACH_JVM = new OfClauseDoc() { - public OfClauseDoc.Kind kind() { - return OfClauseDoc.Kind.EACH_JVM; - } - }; - - public final OfClauseDoc getInstance(PerClause clause) { - if (clause instanceof PerCFlow) { - return EACH_CFLOW; - } - if (clause instanceof PerSingleton) { - return EACH_JVM; - } - if (clause instanceof PerObject) { - return new OfEachObjectDocImpl((PerObject)clause); - } - return null; //??? error - } - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/PackageDocImpl.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/PackageDocImpl.java deleted file mode 100644 index 3715e3928..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/PackageDocImpl.java +++ /dev/null @@ -1,336 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.ajdoc; - -import org.aspectj.ajdoc.AspectDoc; -import org.aspectj.ajdoc.PackageDoc; -import org.aspectj.compiler.base.ast.Type; -import org.aspectj.compiler.base.ast.TypeDec; -import org.aspectj.compiler.crosscuts.AspectJCompiler; - -import com.sun.javadoc.ClassDoc; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * Represents a package in the aspectj-world. - * A package is a passive container of classes given to it. - * It does not enforce visibility rules. However, you can - * purge packages without classes from the static list of packages. - * @author Jeff Palm - */ -public class PackageDocImpl - extends DocImpl - implements org.aspectj.ajdoc.PackageDoc { - - public final static String UNNAMED_PACKAGE = ""; //unnamed-package"; - - private static AjdocCompiler ajdoc = Ajdoc.instance(); - private static AspectJCompiler ajc = ajdoc; - public AspectJCompiler ajc() { return ajc; } - private Set allClasses = new HashSet(); - private Comment comment; - private String name; - - /** - * Only want to create these within the static access. - * - * @param name name of the new package. - */ - private PackageDocImpl(String name) { - this.name = name; - findDocumentation(); - } - - /** - * Adds a class to this package. - * - * @param classDoc The new class. - */ - public void addClass(ClassDoc classDoc) { - allClasses.add(classDoc); - } - - /** - * Attempts to find a class with name className - * in this package. - * - * @param className name of the class to find. - */ - public ClassDoc findClass(String className) { - Type type = ajc.getTypeManager(). - findType(name(), className); - if (type != null) { - return ClassDocImpl.getInstance(type.getTypeDec()); - } - for (Iterator i = allClasses.iterator(); i.hasNext();) { - ClassDoc cd = (ClassDoc)i.next(); - if (className.equals(cd.name())) { - return cd; //todo wes was null? - } - } - return null; - } - - /** - * Returns all the classes in this package. - * - * @return an array of ClassDoc representing all - * the classes in this package. - */ - public ClassDoc[] allClasses() { - return (ClassDoc[])allClasses.toArray(new ClassDoc[allClasses.size()]); - } - - /** - * Returns all the aspects in this package. - * - * @return an array of AspectDoc representing all - * the aspects in this package. - */ - public AspectDoc[] aspects() { - List list = new ArrayList(); - for (Iterator i = allClasses.iterator(); i.hasNext();) { - org.aspectj.ajdoc.ClassDoc doc = (org.aspectj.ajdoc.ClassDoc)i.next(); - if (doc.isAspect()) list.add(doc); - } - return (AspectDoc[])list.toArray - (new AspectDoc[list.size()]); - } - - /** - * Returns all the ordinary classes in this package. - * - * @return an array of ClassDoc representing all - * the ordinary classes in this package. - */ - public ClassDoc[] ordinaryClasses() { - List list = new ArrayList(); - for (Iterator i = allClasses.iterator(); i.hasNext();) { - ClassDoc doc = (ClassDoc)i.next(); - if (doc.isOrdinaryClass()) list.add(doc); - } - return (ClassDoc[])list.toArray - (new ClassDoc[list.size()]); - } - - /** - * Returns all the exceptions in this package. - * - * @return an array of ClassDoc representing all - * the exceptions in this package. - */ - public ClassDoc[] exceptions() { - List list = new ArrayList(); - for (Iterator i = allClasses.iterator(); i.hasNext();) { - ClassDoc doc = (ClassDoc)i.next(); - if (doc.isException()) list.add(doc); - } - return (ClassDoc[])list.toArray - (new ClassDoc[list.size()]); - } - - /** - * Returns all the errors in this package. - * - * @return an array of ClassDoc representing all - * the errors in this package. - */ - public ClassDoc[] errors() { - List list = new ArrayList(); - for (Iterator i = allClasses.iterator(); i.hasNext();) { - ClassDoc doc = (ClassDoc)i.next(); - if (doc.isError()) list.add(doc); - } - return (ClassDoc[])list.toArray - (new ClassDoc[list.size()]); - } - - /** - * Returns all the interfaces in this package. - * - * @return an array of ClassDoc representing all - * the interfaces in this package. - */ - public ClassDoc[] interfaces() { - List list = new ArrayList(); - for (Iterator i = allClasses.iterator(); i.hasNext();) { - ClassDoc doc = (ClassDoc)i.next(); - if (doc.isInterface()) list.add(doc); - } - return (ClassDoc[])list.toArray - (new ClassDoc[list.size()]); - } - - /** - * Returns the name if included -- null otherwise. - * - * @return the name if included -- null otherwise. - */ - public String name() { - return isIncluded() ? name : null; - } - - /** - * Compare based on name(). - * - * @param other other Object. - * @return true if the other Object is a - * PackageDocImpl and has the same name. - */ - public boolean equals(Object other) { - return other instanceof PackageDocImpl && other != null - ? name().equals(((PackageDocImpl)other).name()) - : super.equals(other); - } - - /** - * Returns the name. - * - * @return the name. - */ - public String toString() { - return name(); - } - - private void findDocumentation() { - if (ajdoc == null) return; - String filename = (name.equals("") - ? name - : name.replace('.',File.separatorChar) - + File.separatorChar) + "package.html"; - File html = ajdoc.findFile(filename, false); - if (html == null) return; - String rawCommentText = Util.documentation(html, ajdoc.err()); - - //TODO: should be done in aspect from Aspects.java - //FormalComment comment = new FormalComment(rawCommentText); - setComment(new Comment(this, rawCommentText)); - } - - - /* ------------------------------------------------------------ - * Factory stuff - * ------------------------------------------------------------ - */ - - private static Map namesToPackages = new HashMap(); - - /** - * Returns the collection of known packages. - * - * @return a Collection representing the known packages. - */ - public static Collection packages() { - return namesToPackages.values(); - } - - /** - * Inits the world and AspectJCompiler with these - * packages. - * - * @param world current World. - * @param ajc current compiler. - */ - public static void init(AspectJCompiler ajc) { - PackageDocImpl.ajc = ajc; - if (ajc instanceof AjdocCompiler) { - PackageDocImpl.ajdoc = (AjdocCompiler)ajc; - } - } - - /** - * Returns a package for a TypeDec. - * - * @param typeDec TypeDec whose package is desired. - * @return a PackageDocImpl for a given TypeDec. - */ - public static PackageDocImpl getPackageDoc(TypeDec typeDec) { - return getPackageDoc(typeDec.getPackageName()); - } - - /** - * Returns a package for a name. - * - * @param packageName package name for which to look. - * @return a PackageDocImpl for a given package name. - */ - public static PackageDocImpl getPackageDoc(String packageName) { - return addPackageDoc(packageName); - } - - /** - * Adds a package with name name if it - * already doesn't exist, and returns the new package - * (if own with the same name didn't exist) or the - * existing package. - * - * @param name name of the new package. - * @return current package mapping to - * name. - */ - public static PackageDocImpl addPackageDoc(String name) { - if (name == null) name = UNNAMED_PACKAGE; - PackageDocImpl packageDoc = (PackageDocImpl)namesToPackages.get(name); - if (packageDoc == null) { - packageDoc = new PackageDocImpl(name); - addPackageDoc(packageDoc); - } - return packageDoc; - } - - /** - * Adds the PackageDoc if one doesn't already exist - * with the same name, and returns the existing or created - * package with the same name as the one passed in . - * - * @param packageDoc PackageDoc we want to add. - * @return package in the world with the same - * name as packageDoc. - */ - public static PackageDocImpl addPackageDoc(PackageDoc packageDoc) { - if (packageDoc == null) return null; - return (PackageDocImpl)namesToPackages.put(packageDoc.name(), - packageDoc); - } - - /** - * Sets the include flag to false for empty packages - * todo: remove instead? - */ - public static void excludeEmptyPackages() { - for (Iterator i = packages().iterator(); i.hasNext();) { - PackageDocImpl pkg = (PackageDocImpl)i.next(); - if (pkg.allClasses().length < 1) { - pkg.setIncluded(false); - } - } - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/ParamTagImpl.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/ParamTagImpl.java deleted file mode 100644 index 2f4b1cfc7..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/ParamTagImpl.java +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.ajdoc; - -import com.sun.javadoc.Doc; -import com.sun.javadoc.ParamTag; - -import java.util.Locale; - -/** - * The implementation of a param tag. - * - * @author Jeff Palm - */ -public class ParamTagImpl extends TagImpl implements ParamTag { - - private String parameterComment; - private String parameterName; - - /** - * Constructs the new tag with given parameters. - * - * @param doc the new value for doc. - * @param name the new value for name. - * @param text the new value for text. - * @param locale the new value for locale. - * @param err the new value for err. - */ - public ParamTagImpl(Doc doc, - String name, - String text, - Locale loc, - ErrPrinter err) { - super(doc, name, null, loc, err); - String[] split = split(text); - parameterName = split[0]; - parameterComment = split[1]; - setText(parameterComment); - } - - /** - * Returns the parameter comment. - * - * @return the parameter comment. - */ - public String parameterComment() { - return parameterComment; - } - - /** - * Returns the name of the parameter. - * - * @return the name of the parameter. - */ - public String parameterName() { - return parameterName; - } - - /** - * Returns param. - * - * @return param. - */ - public String kind() { - return "@param"; - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/ParameterImpl.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/ParameterImpl.java deleted file mode 100644 index 04bc96648..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/ParameterImpl.java +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.ajdoc; - -import org.aspectj.compiler.base.ast.FormalDec; - -import com.sun.javadoc.Type; - -public class ParameterImpl implements org.aspectj.ajdoc.Parameter { - - private final FormalDec formalDec; - - public ParameterImpl(FormalDec formalDec) { - this.formalDec = formalDec; - } - - /** - * Returns the name of this formal. - * - * @return the name of this formal. - */ - public String name() { - return formalDec.getId(); - } - - /** - * Returns the type of this formal. - * - * @return the type of this formal. - */ - public Type type() { - return TypeImpl.getInstance(formalDec.getType()); - } - - /** - * Returns the type name of this formal including - * any dimension information. - * - * @return the type name of this formal including - * any dimension information. - */ - public String typeName() { - return type().qualifiedTypeName() + type().dimension(); - } - - public boolean equals(Object o) { - if (!(o instanceof ParameterImpl)) return false; - ParameterImpl p = (ParameterImpl)o; - return typeName().equals(p.typeName()); - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/PointcutDocImpl.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/PointcutDocImpl.java deleted file mode 100644 index bd35c92fc..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/PointcutDocImpl.java +++ /dev/null @@ -1,143 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.ajdoc; - -import org.aspectj.ajdoc.ClassDoc; -import org.aspectj.ajdoc.PointcutDoc; -import org.aspectj.compiler.base.ast.Dec; -import org.aspectj.compiler.base.ast.Formals; -import org.aspectj.compiler.base.ast.NameType; -import org.aspectj.compiler.base.ast.TypeD; -import org.aspectj.compiler.base.ast.TypeDec; -import org.aspectj.compiler.base.ast.TypeDs; -import org.aspectj.compiler.crosscuts.ast.PointcutDec; - -import java.util.Collection; -import java.util.Collections; - -public class PointcutDocImpl - extends ExecutableMemberDocImpl - implements PointcutDoc { - - /** The pointcut to which we delegate. */ - private final PointcutDec pointcutDec; - - public PointcutDocImpl(ClassDoc containingClass, PointcutDec pointcutDec) { - super(containingClass); - this.pointcutDec = pointcutDec; - } - - /** - * Returns a empty list because advice cannot - * be placed on a pointcut. - * - * @return Collection.EMPTY_LIST; - */ - protected Collection createAdvice() { - return Collections.EMPTY_LIST; - } - - /** - * Returns the underlying Dec -- a PointcutDec. - * - * @return the underlying Dec -- a PointcutDec. - */ - protected Dec dec() { - return pointcutDec; - } - - /** - * Returns the Formals of the underlying PointcutDec. - * - * @return the Formals of the underlying PointcutDec. - */ - protected Formals getFormals() { - return pointcutDec.getFormals(); - } - - /** - * Returns null because pointcut cannot throw execptions. - * - * @return null. - */ - public TypeDs getThrows() { - return null; - } - - /** - * Returns the return type of this method. - * - * @return the Type representing the type this - * method returns. - */ - public com.sun.javadoc.Type resultType() { - TypeD typed = pointcutDec.getResultTypeD(); - if (typed == null) return null; //TODO: maybe return VOID - return null; //TODOtyped.getType(); - } - - /** - * Returns the type that nearest super class that defines - * this method. - * - * @return the type that nearest super class that defines - * this method. - */ - public com.sun.javadoc.ClassDoc overriddenClass() { - //TODO: This sucks!!! - TypeDec where = pointcutDec.getDeclaringType().getTypeDec(); - NameType superType = (NameType)where.getSuperClassType(); - while (superType != null) { - PointcutDec pc = Util.pointcutDec(superType, - pointcutDec.getId(), - pointcutDec.getFormals()); - if (pc != null && !pc.getId().equals("NOT_FOUND")) { - // XXX TypeDec result = superType.getTypeDec(); - return null; //TODOresult; - } - if (superType.getTypeDec().getFullName(). - equals("java.lang.Object")) { - return null; - } - superType = (NameType)superType.getTypeDec().getSuperClassType(); - } - return null; - } - - /** - * Returns true. - * - * @return true. - */ - public boolean isPointcut() { - return true; - } - - /** - * Returns true if this method is abstract. - * - * @return true if this method is abstract. - */ - public boolean isAbstract() { - return pointcutDec.isAbstract(); - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/ProgramElementDocImpl.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/ProgramElementDocImpl.java deleted file mode 100644 index 007a56a36..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/ProgramElementDocImpl.java +++ /dev/null @@ -1,203 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.ajdoc; - -import org.aspectj.compiler.base.ast.Dec; -import org.aspectj.compiler.base.ast.Modifiers; -import org.aspectj.compiler.base.ast.NameType; -import org.aspectj.compiler.base.ast.TypeDec; -import org.aspectj.compiler.crosscuts.AspectJCompiler; - -import com.sun.javadoc.ClassDoc; -import com.sun.javadoc.PackageDoc; - -import java.lang.reflect.Modifier; - -public abstract class ProgramElementDocImpl - extends DocImpl - implements org.aspectj.ajdoc.ProgramElementDoc { - - /** The containing ClassDoc. */ - private final ClassDoc containingClass; - - /* - construction of ProgramElementDocImpl must not recursively - invoke construction of instances of subclass ClassDocImpl - or endless recursion will be possible - */ - public ProgramElementDocImpl(ClassDoc containingClass) { - this.containingClass = containingClass; - } - - /** - * Returns the underlying Dec used for a number of methods. - * - * @return the underlying Dec used for a number of methods. - */ - protected abstract Dec dec(); - - /** - * Returns the AspectJCompiler that this tree. Delegates - * to the underlying {@link #dec()}. - * - * @return the AspectJCompiler that compiled this tree. - */ - protected final AspectJCompiler ajc() { - return (AspectJCompiler)dec().getCompiler(); - } - - /** - * Returns this's Comment. - * - * @return the Comment for this Doc. - */ - public Comment getComment() { - if (super.getComment() == null) { - setComment(new Comment(this, dec().getFormalComment(), err())); - } - return super.getComment(); - } - - /** - * Returns the nearest enclosing class. The returned value - * is null if this is a top-level entity. - * - * @return a ClassDoc representing the nearest - * enclosing class. This can be null for - * top-level entities. - */ - public ClassDoc containingClass() { - return containingClass; - } - - /** - * Returns the package in which this Dec was declared. - * - * @return a PackageDoc representing the package - * in which this Dec was declared. - */ - public PackageDoc containingPackage() { - return PackageDocImpl.getPackageDoc(nonNullTypeDec()); - } - - /** - */ - public TypeDec nonNullTypeDec() { - if (dec().getDeclaringType() == null) return null; - return ((NameType)dec().getDeclaringType()).getTypeDec(); - } - - /** - * An int form of this Dec's modifiers. - * - * @return an int form this Dec's modifiers. - * @see java.lang.reflect.Modifier - */ - public int modifierSpecifier() { - return dec().getModifiers().getValue(); - } - - /** - * Returns the modifiers as a String. - * - * @return a String representing to modifiers. - */ - public String modifiers() { - return Modifier.toString(modifierSpecifier()); - } - - /** - * Returns true if this is public. - * - * @return true if this is public. - */ - public boolean isPublic() { - return dec().isPublic(); - } - - /** - * Returns true if this is protected. - * - * @return true if this is protected. - */ - public boolean isProtected() { - return dec().isProtected(); - } - - /** - * Returns true if this is package private. - * - * @return true if this is package private. - */ - public boolean isPackagePrivate() { - Modifiers mods = dec().getModifiers(); - // todo: consider creating Dec.isPackagePrivate() - // todo: consider NPE if mods null - return ((null != mods) && mods.isPackagePrivate()); - } - - /** - * Returns true if this is private. - * - * @return true if this is private. - */ - public boolean isPrivate() { - return dec().isPrivate(); - } - - /** - * Returns true if this is static. - * - * @return true if this is static. - */ - public boolean isStatic() { - return dec().isStatic(); - } - - /** - * Returns true if this is final. - * - * @return true if this is final. - */ - public boolean isFinal() { - return dec().isFinal(); - } - - /** - * Returns the fully-qualified type name of this Dec (not member name). - * - * @return the fully-qualified name. - */ - public String qualifiedName() { - return name(); - } - - /** - * Returns the name -- e.g. ID. - * - * @return the name of the Dec. - */ - public String name() { - return dec().getId(); - } - -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/Quietable.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/Quietable.java deleted file mode 100644 index 055bb2939..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/Quietable.java +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.ajdoc; - -/** - * Utility interface to allow us to shut up - * the writers from redeclaring the generatio - * of files. - * - * @author Jeff Palm - */ -public interface Quietable { - - /** - * Tell someone to be quiet. - */ - public void quiet(); - - /** - * Allow someone to speak again. - */ - public void speak(); -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/RootDocImpl.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/RootDocImpl.java deleted file mode 100644 index f0befd631..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/RootDocImpl.java +++ /dev/null @@ -1,404 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.ajdoc; - -import org.aspectj.compiler.base.ast.TypeDec; -import org.aspectj.compiler.base.ast.World; - -import com.sun.javadoc.ClassDoc; -import com.sun.javadoc.PackageDoc; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -/** - * This is responsible for constituting the world - * of specified[classes|packages] and all classes. - * It ensures that any classes compiled are included (if appropriate) - * but does not ensure that linked classes are. - */ -public class RootDocImpl - extends DocImpl - implements org.aspectj.ajdoc.RootDoc, - Quietable { - - /** The collection of packages specified to be documented. */ - private final Set specifiedPackages; - - /** The collection of types specified to be documented. */ - private final Set specifiedClasses; - - /** The collection of packages visible in this world. */ - private final Set packages = new HashSet(); - - /** The collection of classes visible in this world. */ - private final Set classes = new HashSet(); - - /** The documentation options. */ - private final String[][] options; - - /** The World delegate. */ - private final World world; - - /** Determines whether items are included */ - private final AccessChecker filter; - - public RootDocImpl(World world, String[][] options, - Collection pkgnames, Collection classnames, - AccessChecker filter) { - this.world = world; - this.options = options; - this.filter = (null != filter ? filter : AccessChecker.PUBLIC); - Set set = createSpecifiedPackages(pkgnames); - specifiedPackages = set; // modifiable to prune empty packages - set = createSpecifiedClasses(classnames); - specifiedClasses = Collections.unmodifiableSet(set); - // adds all world classes and packages for classes and packages - // addWorldTypes(); // todo re-enable as needed - // make sure specified are added - should duplicate world - // but should come after since packages are removed if empty - addSpecifiedPackages(); - addSpecifiedClasses(); - setupDominatesRelations(); - ensureWorldInclusion(); - } - /* ------------------------------------------------------------ - * Implementation of RootDoc - * ------------------------------------------------------------ - */ - - /** - * Returns the classes visible in this world. - * - * @return an array of ClassDoc representing the visible - * classes in this world. - */ - public ClassDoc[] classes() { - return (ClassDoc[])classes.toArray - (new org.aspectj.ajdoc.ClassDoc[classes.size()]); - } - - /** - * Returns a type visible in this world - * for the name className. If there is - * no visible package, this method will return - * null. - * - * @return an instance of ClassDoc in this world - * that corresponds to className. - * null is returned if there exists - * no such visible type named className. - */ - public ClassDoc classNamed(String className) { - ClassDoc[] docs = classes(); - for (int i = 0; i < docs.length; i++) { - ClassDoc doc = docs[i]; - if (doc.name().equals(className)) { - return doc; - } - } - return null; - } - - /** - * Returns a package visible in this world - * for the name packageName. If there is - * no visible package, this method will return - * null. - * - * @return an instance of PackageDoc in this world - * that corresponds to packageName. - * null is returned if there exists - * no such visible package named packageName. - */ - public PackageDoc packageNamed(String packageName) { - for (Iterator i = packages.iterator(); i.hasNext();) { - PackageDoc doc = (PackageDoc)i.next(); - if (doc.name().equals(packageName)) { - return doc; - } - } - return null; - } - - /** - * Returns the underlying world. - * - * @return an instance of World representing all - * the CompilationUnits. - */ - public World world() { - return world; - } - - /** - * Returns the documentation options. - * - * @return the documentation options. - */ - public String[][] options() { - return options; - } - - /** - * Returns the types specified to be documented. - * - * @return an array of ClassDoc representing the - * specified types. - */ - public ClassDoc[] specifiedClasses() { - return (ClassDoc[])specifiedClasses.toArray - (new org.aspectj.ajdoc.ClassDoc[specifiedClasses.size()]); - } - - /** - * Returns the packages specified to be documented. - * - * @return an array of PackageDoc representing the - * specified packages. - */ - public PackageDoc[] specifiedPackages() { - return (PackageDoc[])specifiedPackages.toArray - (new org.aspectj.ajdoc.PackageDoc[specifiedPackages.size()]); - } - - - /* ------------------------------------------------------------ - * Implementation of Quietable - * ------------------------------------------------------------ - */ - - /** true when notices should be printed. */ - private boolean notice = true; - - /** Supresses output notices. */ - public void quiet() { notice = false; } - - /** Allows output notices. */ - public void speak() { notice = true; } - - - /* ------------------------------------------------------------ - * Implementation of DocErrReporter - * ------------------------------------------------------------ - */ - - /** - * Prints the error message msg using - * the current error handler. - * - * @param msg the error message. - */ - public void printError(String msg) { - err().printError(msg); - } - - /** - * Prints the notice message msg using - * the current error handler. - * - * @param msg the notice message. - */ - public void printNotice(String msg) { - if (notice) err().printNotice(msg); - } - - /** - * Prints the warning message msg using - * the current error handler. - * - * @param msg the warning message. - */ - public void printWarning(String msg) { - err().printWarning(msg); - } - - - /* ------------------------------------------------------------ - * Implementation of Doc - * ------------------------------------------------------------ - */ - - /** - * Returns null. - * - * @return null. - */ - public String name() { - return "who knows???"; - } - - - /* ------------------------------------------------------------ - * Helper methods - * ------------------------------------------------------------ - */ - - /** - * Creates only PackageDocs that were included on the command - * line, even if they are empty. Should be used only for - * specifiedPackages. - */ - private HashSet createSpecifiedPackages(Collection pkgnames) { - HashSet result = new HashSet(); - for (Iterator i = pkgnames.iterator(); i.hasNext();) { - String pkgname = (String)i.next(); - PackageDocImpl pkgdoc = PackageDocImpl.getPackageDoc(pkgname); - pkgdoc.setIncluded(true); - result.add(pkgdoc); - } - return result; - } - private void addWorldTypes() { - for (Iterator i = world.getTypes().iterator(); i.hasNext();) { - TypeDec td = (TypeDec)i.next(); - ClassDocImpl cd = ClassDocImpl.getInstance(td); - addClass(cd); - cd.setIncluded(filter.canAccess(td)); - } - } - - /** - * Creates only ClassDocs that were included on the command - * line, and then only if they pass the filter. - * Should be used only for specifiedClasses. - * todo: createClasses uses to use all classes if no names - */ - private HashSet createSpecifiedClasses(Collection classnames) { - HashSet result = new HashSet(); - if (classnames != null) { - for (Iterator i = classnames.iterator(); i.hasNext();) { - String classname = (String)i.next(); - for (Iterator j = world.getTypes().iterator(); j.hasNext();) { - TypeDec td = (TypeDec)j.next(); - if (filter.canAccess(td)) { - ClassDoc cd = ClassDocImpl.getInstance(td); - if (cd.qualifiedName().equals(classname)) { - result.add(cd); - // add inner classes since not specified explicitly - ClassDoc[] inners = cd.innerClasses(); // no cycles, right? - if (null != inners) { - for (int l = 0; l < inners.length; l++) { - result.add(inners[l]); - } - } - break; - } - } - } - // todo: warn if class specified but not in world? - } - } - return result; - } - - private void addSpecifiedClasses() { - for (Iterator i = new ArrayList(specifiedClasses).iterator(); i.hasNext();) { - ClassDoc cd = (ClassDoc)i.next(); - addClass(cd); - } - } - - private void addSpecifiedPackages() { - for (Iterator i = new ArrayList(specifiedPackages).iterator(); i.hasNext();) { - PackageDoc pd = (PackageDoc)i.next(); - ClassDoc[] allClasses = pd.allClasses(); - if (allClasses.length == 0) { - specifiedPackages.remove(pd); - } else { - for (int j = 0; j < allClasses.length; j++) { - addClass(allClasses[j]); - } - } - } - } - - /** - * If filter accepts this ClassDoc, - * Add it and and inner classes to classes - * and add package to packages. - */ - private void addClass(ClassDoc cd) { - if (null == cd) return; - ClassDocImpl impl = (ClassDocImpl) cd; - if (filter.canAccess(impl.typeDec()) - && (!classes.contains(impl))) { - impl.setIncluded(true); - classes.add(impl); - packages.add(impl.containingPackage()); - ClassDoc[] inners = impl.innerClasses(); - for (int i = 0; i < inners.length; i++) { - addClass(inners[i]); - } - } // todo: flag classes not added? - } - - /** Read all classes to find any dominates relations */ - private void setupDominatesRelations() { - // Find just the aspects - List aspects = new ArrayList(); - ClassDoc[] classes = classes(); - for (int i = 0; i < classes.length; i++) { - ClassDocImpl cd = (ClassDocImpl)classes[i]; - if (cd.isAspect()) { - aspects.add(cd); - } - } - - // Iterate over the aspects, if - for (Iterator i = aspects.iterator(); i.hasNext();) { - AspectDocImpl aspect1 = (AspectDocImpl)i.next(); - for (Iterator j = aspects.iterator(); j.hasNext();) { - AspectDocImpl aspect2 = (AspectDocImpl)j.next(); - if (aspect1.dominates(aspect2)) { - aspect1.addDominatee(aspect2); - aspect2.addDominator(aspect1); - } - } - } - } - - /** - * Ensure compiled classes are included if they pass the filter - * and excluded otherwise. - * todo: The set of types available includes the world plus reachable - * types from there; I would like to exclude the reachable ones, - * but do not know how. - */ - private void ensureWorldInclusion() { - for (Iterator i = world.getTypes().iterator(); i.hasNext();) { - TypeDec td = (TypeDec)i.next(); - ClassDocImpl cd = ClassDocImpl.getInstance(td); - boolean isIncluded = cd.isIncluded(); - // todo: update to consider enclosing class privileges - boolean shouldInclude = filter.canAccess(td); - if (shouldInclude != isIncluded) { - cd.setIncluded(shouldInclude); - } - } - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/RootDocMaker.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/RootDocMaker.java deleted file mode 100644 index efe1f322d..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/RootDocMaker.java +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.ajdoc; - -import com.sun.javadoc.DocErrorReporter; -import com.sun.javadoc.RootDoc; - -import java.util.List; - -/** - * Interface specifying types that - * can produce RootDocs. - * - * @author Jeff Palm - */ -public interface RootDocMaker { - - /** - * Returns a RootDoc using the passed in parameters. - * Throw a CannotMakeRootDocException is something - * goes awry. - * - * @param sourcepath sourcepath to use. - * @param classpath classpath to use. - * @param bootclasspath bootclasspath to use. - * @param extdirs extdirs to use. - * @param flags flags to use. - * @param encoding encoding to use. - * @param locale locale to use. - * @param source source to use. - * @param filenamesAndPackages filenamesAndPackages to use. - * @param options options to use. - * @param err ErrPrinter to use. - * @param programName program name to use. - * @param filter filter to use. - * @return a RootDoc. - */ - public RootDoc makeRootDoc(String sourcepath, - String classpath, - String bootclasspath, - String extdirs, - long flags, - String encoding, - String locale, - String source, - List filenamesAndPackages, - List options, - DocErrorReporter err, - String programName, - AccessChecker filter) - throws CannotMakeRootDocException; - -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/SeeTagImpl.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/SeeTagImpl.java deleted file mode 100644 index f7324b818..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/SeeTagImpl.java +++ /dev/null @@ -1,874 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.ajdoc; - -import org.aspectj.ajdoc.AdviceDoc; -import org.aspectj.ajdoc.AspectDoc; -import org.aspectj.ajdoc.PointcutDoc; -import org.aspectj.compiler.base.JavaCompiler; -import org.aspectj.compiler.base.ast.ASTObject; - -import com.sun.javadoc.ClassDoc; -import com.sun.javadoc.ConstructorDoc; -import com.sun.javadoc.Doc; -import com.sun.javadoc.FieldDoc; -import com.sun.javadoc.MemberDoc; -import com.sun.javadoc.MethodDoc; -import com.sun.javadoc.PackageDoc; -import com.sun.javadoc.Parameter; -import com.sun.javadoc.SeeTag; - -import java.io.PrintStream; -import java.util.ArrayList; -import java.util.List; -import java.util.Locale; -import java.util.StringTokenizer; - -/** - * Implementation of see tags in the aspectj-world. - * See source for bug comments - * @author Jeff Palm - */ -public class SeeTagImpl extends TagImpl implements SeeTag { - /* - * This implementation handles - *
{@link  package.class#member  label}
- * @see  package.class#member  label
- * @see "some reference"
- * @see 
. - * It has errors since the tag-separating code which provides - * input is wrong, and it's very weak in how it handles - * text and URLs. Most of the action is in resolve(). - */ - - /** The package name specified by the user -- may be null. */ - private String packageName; - - /** The class name specified by the user -- may be null. */ - private String className; - - /** The member name specified by the user -- may be null. */ - private String memberName; - - /** The referenced package. */ - private PackageDoc packageDoc; - - /** The referenced class. */ - private ClassDoc classDoc; - - /** The referenced member. */ - private MemberDoc memberDoc; - - /** The label associated with the tag. */ - private String label = ""; - - /** A shared instance of the compiler -- a little hacky. */ - private static JavaCompiler ajc = AjdocCompiler.instance(); - - /** - * Constructs the new tag with given parameters and - * calls resolve to parse the class, package, and members. - * - * @param doc the new value for doc. - * @param name the new value for name. - * @param text the new value for text. - * @param locale the new value for locale. - * @param err the new value for err. - */ - public SeeTagImpl(Doc doc, - String name, - String text, - Locale loc, - ErrPrinter err) { - super(doc, name, text, loc, err); - resolve(); - } - - /** - * Returns the label. - * - * @return the label. - */ - public String label() { - return label; - } - - /** - * Returns the referenced package's name. - * This can be null. - * - * @return the referenced package's name. - */ - public String referencedPackageName() { - return packageName; - } - - /** - * Returns the referenced package. - * This can be null. - * - * @return a PackageDoc with name packageName. - */ - public PackageDoc referencedPackage() { - look(); - return packageDoc; - } - - /** - * Returns the referenced class's name. - * This can be null. - * - * @return the referenced class's name. - */ - public String referencedClassName() { - return className; - } - - /** - * Returns the referenced class. - * This can be null. - * - * @return a ClassDoc with name className. - */ - public ClassDoc referencedClass() { - look(); - return classDoc; - } - - /** - * Returns the referenced members's name. - * This can be null. - * This can be null. - * - * @return the referenced class's name. - */ - public String referencedMemberName() { - return memberName; - } - - /** - * Returns the referenced member. - * This can be null. - * - * @return a ClassDoc with name memberName. - */ - public MemberDoc referencedMember() { - look(); - return memberDoc; - } - - /** - * Returns see. - * - * @return see. - */ - public String kind() { - return "@see"; - } - - protected JavaCompiler ajc() { - if (ajc != null) { - return ajc; - } else if (doc() instanceof ASTObject) { - return ajc = ((ASTObject)doc()).getCompiler(); - } else if (doc() instanceof PackageDocImpl) { - return ajc = ((PackageDocImpl)doc()).ajc(); - } - return null; - } - - void debugState(String m, PrintStream err) { - if (System.getProperty("seetag.debug") != null) { - if (null == err) err = System.err; - err.println("\t______________________ " + m - + "\n\tpackageName: "+packageName - + "\n\t packageDoc: " +packageDoc - + "\n\t className: " +className - + "\n\t classDoc: " +classDoc - + "\n\t memberName: " +memberName - + "\n\t memberDoc: " +memberDoc - + "\n\t label: " +label - ); - } - } - private boolean looked = false; - private void look() { - if (!looked) { - looked = true; - dolook(); - } - debugState("SeeTagImpl.look()", null); - } - - private void dolook() { - - // For null or empty classnames set the current doc - // to the referenced class - if (className == null || className.length() < 1) { - classDoc = classDoc(doc()); - } else { - - // Use the class in which this doc is contained - // as a starting point... - ClassDoc container = classDoc(doc()); - - // ..and try to find the class from there - if (container == null) { - //TODO: Find class somewhere else - } else { - String fullName; - if (packageName == null || packageName.length() < 1) { - fullName = className; - } else { - fullName = packageName + '.' + className; - } - - // As per the language spec... - // http://java.sun.com/docs/books/jls/second_edition/ (con't) - // html/names.doc.html#32725 - // We must first consider types before identifiers, - // therefore, if there is no right parent in the member name - // we have to consider this first an inner class, and if - // one is found set the member name to nul - if (memberName != null && - memberName.indexOf('(') == -1) { - classDoc = container.findClass(fullName + '.' + memberName); - - // If we found an inner class, don't look for a member - if (classDoc != null) { - memberName = null; - } - } - - // Now if we didn't find an inner class, just look - // up the full name - if (classDoc == null) { - classDoc = container.findClass(fullName); - } - } - } - - // If we found a class, then the package is that - // class's contained package - if (classDoc != null) { - packageDoc = classDoc.containingPackage(); - } else if (packageName == null) { - - // If we didn't find a class, but the class name - // contains no periods, maybe the class name's really - // a package name - if (classDoc == null && className != null && - className.indexOf('.') == -1) { - packageDoc = PackageDocImpl.getPackageDoc(className); - } - - // Otherwise, if the referenced class isn't null, set the - // referenced package to that class's contained package - else if (classDoc != null) { - packageDoc = classDoc.containingPackage(); - } - - // Lastly, if the current doc is a package (i.e. package.html) - // then set the referenced package to the current doc - else if (doc() instanceof PackageDoc) { - packageDoc = (PackageDoc)doc(); - } - } else { - - // Look for the fully qualified name of the - // package elsewhere - packageDoc = PackageDocImpl.getPackageDoc(packageName != null - ? packageName - : ""); - } - - // Look for the member if the member name wasn't null - if (memberName != null) { - lookForMember(memberName, (org.aspectj.ajdoc.ClassDoc)classDoc); - } - } - - private void lookForMember(String spec, - org.aspectj.ajdoc.ClassDoc container) { - int ilparen = spec.indexOf('('); - String name; - - // No parens mean a field or a method - // The order is for looking is: - // [1] field - // [2] method - // [3] pointcut - if (ilparen == -1) { - name = spec; - if ((memberDoc = fieldDoc(name, container)) != null) { - return; - } - if ((memberDoc = methodDoc(name, container, null)) != null) { - return; - } - if ((memberDoc = pointcutDoc(name, container, null)) != null) { - return; - } - } else { - name = spec.substring(0, ilparen); - } - int irparen = spec.lastIndexOf(')'); - - // Crop out the parameters - String paramsString; - if (irparen != -1) { - paramsString = spec.substring(ilparen+1, irparen); - } else { - paramsString = spec.substring(ilparen+1, spec.length()-1); - } - - // Convert the raw parameters to an array - String[] paramNames = paramNames(paramsString); - - // Try to match the name and parameters if the following order: - // [1] method - // [2] constructor - // [3] pointcut - // [4] advice - if ((memberDoc = methodDoc(name, container, paramNames)) != null) { - return; - } - if ((memberDoc = constructorDoc(container, paramNames)) != null) { - return; - } - if ((memberDoc = pointcutDoc(name, container, paramNames)) != null) { - return; - } - if (container instanceof AspectDoc) { - if ((memberDoc = adviceDoc(name, - (AspectDoc)container, - paramNames)) != null) { - return; - } - } - } - - private String[] paramNames(String restNoParens) { - if (restNoParens == null || restNoParens.length() == 0) { - return new String[0]; - } - List params = new ArrayList(); - for (StringTokenizer t = new StringTokenizer(restNoParens, ",", false); - t.hasMoreTokens();) { - String spec = t.nextToken().trim(); - int ispace = spec.indexOf(' '); - if (ispace != -1) { - spec = spec.substring(0, ispace); - } - params.add(spec); - } - return (String[])params.toArray(new String[params.size()]); - } - - private FieldDoc fieldDoc(String name, ClassDoc container) { - for (ClassDoc cd = container; cd != null; cd = cd.superclass()) { - FieldDoc[] docs = cd.fields(); - for (int i = 0, N = docs.length; i < N; i++) { - if (docs[i].name().equals(name)) { - return docs[i]; - } - } - } - return null; - } - - private PointcutDoc pointcutDoc(String name, - org.aspectj.ajdoc.ClassDoc container, - String[] paramNames) { - if (null == name) return null; // XXX warn or error - - for (org.aspectj.ajdoc.ClassDoc cd = container; - cd != null; - cd = (org.aspectj.ajdoc.ClassDoc)cd.superclass()) { - PointcutDoc[] docs = cd.pointcuts(); - if (null == docs) { - continue; - } - for (int i = 0, N = docs.length; i < N; i++) { - PointcutDoc md = docs[i]; - if ((null != md) - && (name.equals(md.name())) - && ((null == paramNames) - || parametersMatch(md.parameters(), paramNames, container))) { - return md; - } - } - } - return null; - } - - private MethodDoc methodDoc(String name, ClassDoc container, - String[] paramNames) { - for (ClassDoc cd = container; cd != null; cd = cd.superclass()) { - MethodDoc[] docs = cd.methods(); - for (int i = 0, N = docs.length; i < N; i++) { - MethodDoc md = docs[i]; - if (!md.name().equals(name)) { - continue; - } - if (paramNames == null) { - return md; - } else { - if (parametersMatch(md.parameters(), - paramNames, - container)) { - return md; - } - } - } - } - return null; - } - - private ConstructorDoc constructorDoc(ClassDoc container, - String[] paramNames) { - for (ClassDoc cd = container; cd != null; cd = cd.superclass()) { - ConstructorDoc[] docs = cd.constructors(); - for (int i = 0, N = docs.length; i < N; i++) { - ConstructorDoc md = docs[i]; - if (paramNames == null) { - return md; - } else { - if (parametersMatch(md.parameters(), - paramNames, - container)) { - return md; - } - } - } - } - return null; - } - - private AdviceDoc adviceDoc(String name, - AspectDoc container, - String[] paramNames) { - - AspectDoc cd = container; - while (cd != null) { - AdviceDoc[] docs = cd.advice(); - for (int i = 0, N = docs.length; i < N; i++) { - AdviceDoc md = docs[i]; - if (!(name.equals(md.name()))) { - continue; - } - if (paramNames == null) { - return md; - } else { - if (parametersMatch(md.parameters(), - paramNames, - container)) { - return md; - } - } - } - Object o = cd.superclass(); - if (o instanceof AspectDoc) { - cd = (AspectDoc) o; - } else { - cd = null; - } - } - return null; - } - - private boolean parametersMatch(Parameter[] params, - String[] paramNames, - ClassDoc container) { - if ((null == params) || (null == paramNames) || (null == container)) { - return false; - } - if (params.length != paramNames.length) { - return false; - } - for (int i = 0, N = params.length; i < N; i++) { - com.sun.javadoc.Type type1 = params[i].type(); - com.sun.javadoc.Type type2 = TypeImpl.getInstance(paramNames[i], - container); - if ((null == type1) || (!type1.equals(type2))) { - return false; - } - } - return true; - } - - private ClassDoc classDoc(Doc d) { - if (d instanceof ClassDoc) { - return (ClassDoc)d; - } - if (d instanceof MemberDoc) { - return ((MemberDoc)d).containingClass(); - } - return null; - } - - /** find next (matching) char x, ignoring instances - * preceded by escape character '\'. - */ - private static int findNextChar(final String s, final int start, final char x) { // XXX to Util - if ((null != s) && (start >= 0)) { - boolean escaped = false; - for (int i = start; i < s.length(); i++) { - char c = s.charAt(i); - if (('\\' == c) && !escaped) { - escaped = true; - continue; - } else if ((x == c) && !escaped) { - return i; - } - if (escaped) { - escaped = false; - } - } - } - return -1; - } - - /** - * This looks a bit hideous, and it is, I had a state diagram - * with every thing labled, but I lost it -- sorry ;). - *
{@link  package.class#member  label} 
- * http://java.sun.com/j2se/1.3/docs/tooldocs/solaris/javadoc.html#\{@link} - */ - private void resolve() { - String str = text(); - - if (str == null || str.length() < 1) { - return; - } - - str = str.trim(); - - int N = str.length(); - - char first = str.charAt(0); - if (first == '<') { - if ((N < 4) || (str.charAt(N-1) != '>')) { - err().error("see_tag_unterminated_url",str); - } else { - char second = str.charAt(1); - if ((second == 'a') || (second == 'A')) { - label = str; - } else { - err().error("see_tag_unterminated_url",str); // XXX wrong message - } - } - return; - } - - if (first == '"') { - if (N == 1) { - err().error("see_tag_unterminated_string",str); - } else if (str.charAt(N-1) == '"') { - label = str; - } else { - int loc = findNextChar(str, 1, '"'); - if (-1 == loc) { - err().error("see_tag_unterminated_string",str); - } else { - label = str.substring(0, loc+1); - } - } - return; - } - // XXX but does not handle URLs? - char c = 0; - int state = 0, next = 0; - boolean finished = false; - - int iclassEnd = -1; - int isharp = -1; - int ilastDot = -1; - int iStartLabel = -1; - int iEndMemberLabel = -1; // membername plus parameters - boolean sharp = false; - int i; - done: - for (i = 0; i < N; i++, state = next) { - c = str.charAt(i); - switch (state) { - - case 0: // seeking initial: [type|memberName] - if (ident(c)) { next = 1; } - else if (c == '#') { next = 2; iclassEnd = i-1; } - else { - err().error("see_tag_dot_sharp_or_id","\""+c+"\"@0",str); - return; - } - break; - - case 1: // reading initial [type|memberName] - if (ident(c)) { next = 1; } - else if (c == '#') { next = 2; iclassEnd = i-1; } - else if (c == '.') { next = 3; ilastDot = i; } - else if (space(c)) { iclassEnd = i-1; next = 16; } - else { - err().error("see_tag_invalid_package_or_class","\""+c+"\"@1",str); - return; - } - break; - - case 2: // start reading membername (field only?) - sharp = true; - if (ident(c)) { next = 4; isharp = i; } - else { - err().error("see_tag_expecting_field_name","\""+c+"\"@2",str); - return; - } - break; - - case 3: // reading qualified type name - if (ident(c)) { next = 1; } - else { - err().error("see_tag_invalid_id","\""+c+"\"@3",str); - return; - } - break; - - case 4: // reading membername - if (ident(c)) { next = 4; } - else if (space(c)) { next = 13; iEndMemberLabel = i-1;} - else if (c == '(') { next = 15; } - else { - err().error("see_tag_invalid_param_start","\""+c+"\"@4",str); - return; - } - break; - - case 5: // start reading parms - if (ident(c)) { next = 6; } - else if (space(c)) { next = 5; } - else if (c == ')') { next = 13; iEndMemberLabel = i;} - else { - err().error("see_tag_premature_param_end","\""+c+"\"@5",str); - return; - } - break; - - case 6: // reading parm (or type?) - if (ident(c)) { next = 6; } - else if (c == '.') { next = 7; } - else if (c == '[') { next = 8; } - else if (space(c)) { next = 10; } - else if (c == ',') { next = 12; } - else if (c == ')') { iEndMemberLabel = i; next = 16; } - else { - err().error("see_tag_invalid_parameter_type","\""+c+"\"@6",str); - return; - } - break; - - case 7: // reading qualified parameter type . - if (ident(c)) { next = 6; } - else { - err().error("see_tag_invalid_parameter_type_ident","\""+c+"\"@7",str); - return; - } - break; - - case 8: // reading end of [] - if (c == ']') { next = 9; } - else if (space(c)) { next = 8; } - else { - err().error("see_tag_unterminated_array_type","\""+c+"\"@8",str); - return; - } - break; - - case 9: // maybe completed parameter type - if (c == '[') { next = 8; } - else if (space(c)) { next = 10; } - else if (c == ',') { next = 12; } - else if (c == ')') { iEndMemberLabel = i; next = 16; } - else { - err().error("see_tag_invalid_parameter_type","\""+c+"\"@9",str); - return; - } - break; - - case 10: // completed parm type? - if (ident(c)) { next = 11; } - else if (space(c)) { next = 12; } - else if (c == ',') { next = 14; } - else if (c == ')') { iEndMemberLabel = i; next = 16; } - else { - err().error("see_tag_invalid_parameters","\""+c+"\"@10",str); - return; - } - break; - - case 11: // reading parm type? - if (ident(c)) { next = 11; } - else if (space(c)) { next = 12; } - else if (c == ',') { next = 14; } - else if (c == ')') { iEndMemberLabel = i; next = 16; } - else { - err().error("see_tag_invalid_parameters","\""+c+"\"@11",str); - return; - } - break; - - case 12: // looking for next parm? - if (space(c)) { next = 12; } - else if (c == ',') { next = 14; } - else if (ident(c)) { next = 15; } - else if (c == ')') { iEndMemberLabel = i; next = 16; } - else { - err().error("see_tag_invalid_parameters","\""+c+"\"@12",str); - return; - } - break; - - case 13: // seeking parms or label - if (space(c)) { next = 13; } - else if (c == '(') { next = 5; } // start reading parms - else if (ident(c)) { // start reading label - iStartLabel = i; next = 17; - } - else { - err().error("see_tag_invalid_parameters","\""+c+"\"@13",str); - return; - } - break; - - case 14: // type name (or identifier) - if (ident(c)) { next = 6; } - else if (space(c)) { next = 14; } - else { - err().error("see_tag_expecting_typename_or_whitespace","\""+c+"\"@14",str); - return; - } - break; - - case 15: // reading parms - if (ident(c)) { next = 6; } - else if (space(c)) { next = 15; } - else if (c == ')') { iEndMemberLabel = i; next = 16; } - else { - err().error("see_tag_premature_param_end","\""+c+"\"@15",str); - return; - } - break; - case 16 : // seeking label - if (ident(c)) { iStartLabel = i; next = 17; } - else if (space(c)) { next = 16; } - else { - String s = "\"" + c + "\" in \"" + text() + "\""; - err().error("see_tag_premature_param_end",s + "@16",str); - return; - } - break; - case 17 : // reading label - may have internal spaces - if (ident(c)) { next = 17; } - else if (space(c)) { next = 17; } - // XXX known limitation - labels may only be ident + whitespace (no -) - else { - err().error("see_tag_premature_param_end","\""+c+"\"@17",str); - return; - } - break; - } - - if (i == N-1) { - finished = next == -1 - || next == 1 || next == 13 - || next == 16 || next == 17 - || next == 4 || next == 12; - } - - } - - if (sharp) { - if (ilastDot != -1) { - packageName = str.substring(0, ilastDot); - } - } else { - if (ilastDot == -1) { - //packageName = str; - } else { - packageName = str.substring(0, ilastDot); - } - } - - if (sharp) { - if (iclassEnd != -1) { - if (ilastDot == -1) { - className = str.substring(0, iclassEnd+1); - } else { - className = str.substring(ilastDot+1, iclassEnd+1); - } - } - } else { - if (ilastDot == -1) { - if (iclassEnd != -1) { - className = str.substring(0, iclassEnd+1); - } else { - className = str; - } - } else { - if (iclassEnd != -1) { - className = str.substring(ilastDot+1, iclassEnd+1); - } else { - className = str.substring(ilastDot+1); - } - } - } - - if (sharp) { - if (-1 != iEndMemberLabel) { - memberName = str.substring(isharp, iEndMemberLabel+1).trim(); - } else { - memberName = str.substring(isharp).trim(); - } - // hack to remove spaces between method name and parms - int parmLoc = memberName.indexOf("("); - if (-1 != parmLoc) { - int spaceLoc = memberName.indexOf(" "); - if ((-1 != spaceLoc) && (spaceLoc < parmLoc)) { - memberName = memberName.substring(0,spaceLoc) - + memberName.substring(parmLoc).trim(); - } - } - } - - if (!finished) { - err().error("see_tag_prematurely_done",str); - } else { - if (iStartLabel != -1) { - label = str.substring(iStartLabel).trim(); - } else if (i < N-1) { // when does this happen? - label = str.substring(i).trim(); - } - } - } - - // test-only methods - String getPackageName() {return packageName;} - String getClassName() { return className;} - String getMemberName() { return memberName; } - String getLabel() { return label; } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/SerialFieldTagImpl.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/SerialFieldTagImpl.java deleted file mode 100644 index 3b00549fc..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/SerialFieldTagImpl.java +++ /dev/null @@ -1,173 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.ajdoc; - -import com.sun.javadoc.ClassDoc; -import com.sun.javadoc.Doc; -import com.sun.javadoc.SerialFieldTag; - -import java.util.Locale; - -/** - * Represents a serial field tag in the aspectj-world. - * - * @author Jeff Palm - */ -public class SerialFieldTagImpl - extends TagImpl implements SerialFieldTag, - Comparable { - - private String description; - private String fieldName; - private String fieldType; - private ClassDoc fieldTypeDoc; - - /** - * Constructs the new tag with given parameters and - * then tries to resolve the names of the text. - * - * @param doc the new value for doc. - * @param name the new value for name. - * @param text the new value for text. - * @param locale the new value for locale. - * @param err the new value for err. - */ - public SerialFieldTagImpl(Doc doc, - String name, - String text, - Locale loc, - ErrPrinter err) { - super(doc, name, text, loc, err); - resolveNames(text); - } - - /** - * Returns the description. - * - * @return the description. - */ - public String description() { - return description; - } - - /** - * Returns the field name. - * - * @return the field name. - */ - public String fieldName() { - return fieldName; - } - - /** - * Returns the field type. - * - * @return the field type. - */ - public String fieldType() { - return fieldType; - } - - /** - * Returns the class of the field type. - * - * @return a ClassDoc with type name fieldType. - */ - public ClassDoc fieldTypeDoc() { - return fieldTypeDoc; - } - - //XXX - //TODO: implement - public int compareTo(Object other) { - return -1; - } - - /** - * Returns serialField. - * - * @return serialField. - */ - public String kind() { - return "@serialField"; - } - - - private void resolveNames(String str) { - // - // @serialField field-name field-type field-description - // - if (str == null || (str = str.trim()).length() < 1) return; - final int N = str.length(); - - int i = 0; - int start; - - // Find the first char in the field-name - start = i; - if (i < N && !start(str.charAt(i++))) { - err().error("serialField_tag_invalid_field_name_start", - ""+str.charAt(i)); - return; - } - - // Find the rest of the field-name - while (i < N && !space(str.charAt(i))) { - if (!ident(str.charAt(i))) { - err().error("serialField_tag_invalid_field_name_part", - ""+str.charAt(i)); - return; - } - i++; - } - - // Found the field-name - fieldName = str.substring(start, i).trim(); - - // Find the first char in the field-type - start = i; - if (i < N && !start(str.charAt(i++))) { - err().error("serialField_tag_invalid_type_name_start", - ""+str.charAt(i)); - return; - } - - // Find the rest of the field-name - while (i < N && !space(str.charAt(i))) { - if (!(str.charAt(i) == '[' || - str.charAt(i) == ']' || - ident(str.charAt(i)))) { - err().error("serialField_tag_invalid_type_name_part", - ""+str.charAt(i)); - return; - } - } - - // Found the field-type - fieldType = str.substring(start, i).trim(); - - // The rest is the field-description - if (i < N) { - description = str.substring(i).trim(); - } - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/TagImpl.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/TagImpl.java deleted file mode 100644 index 4fe4effc5..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/TagImpl.java +++ /dev/null @@ -1,181 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.ajdoc; - -import com.sun.javadoc.Doc; -import com.sun.javadoc.Tag; - -import java.util.Locale; - -public class TagImpl implements Tag { - - private Locale locale; - private ErrPrinter err; - private String name; - private String text; - private Doc doc; - - /** - * Constructs the new tag with given parameters. - * - * @param doc the new value for doc. - * @param name the new value for name. - * @param text the new value for text. - * @param locale the new value for locale. - * @param err the new value for err. - */ - public TagImpl(Doc doc, - String name, - String text, - Locale locale, - ErrPrinter err) { - this.doc = doc; - this.name = name; - this.text = text; - this.locale = locale; - this.err = err; - } - - /** - * Returns the Doc associated with this tag. - * - * @return the Doc associated with this tag. - */ - protected final Doc doc() { - return doc; - } - - /** - * Returns the ErrPrinter associated with this tag. - * - * @return the ErrPrinter associated with this tag. - */ - protected final ErrPrinter err() { - return err == null ? ErrPrinter.instance : err; - } - - /** - * Delegates to {@link Util#start(char)}. - * - * @see Util#start(char) - */ - protected final static boolean start(char c) { return Util.start(c); } - - /** - * Delegates to {@link Util#ident(char)}. - * - * @see Util#ident(char) - */ - protected final static boolean ident(char c) { return Util.ident(c); } - - /** - * Delegates to {@link Util#space(char)}. - * - * @see Util#space(char) - */ - protected final static boolean space(char c) { return Util.space(c); } - - /** - * Delegates to {@link Util#split(char)}. - * - * @see Util#split(char) - */ - protected final static String[] split(String s) { return Util.split(s); } - - /** - * Returns the name. - * - * @return the name. - */ - public String name() { - return name; - } - - /** - * Returns the kind followed by the String text. - * - * @return kind followed by the String text. - */ - public String toString() { - return kind() + " " + text; - } - - /** - * Returns the kind of tag. - * - * @return kind of the tag. - */ - public String kind() { - return name; - } - - /** - * Returns the String text of this tag. - * - * @return String text of this tag. - */ - public String text() { - return text; - } - - /** - * Sets the String text. - * - * @param text the new value for text. - */ - protected void setText(String text) { - this.text = text; - } - - /** - * Returns the locale. - * - * @return the locale. - */ - public Locale locale() { - return locale; - } - - /** - * Returns the inline tags in this tag. - * - * @return an array of Tag representing the inline - * tags in this tag. - * @see Util#inlineTags - */ - public Tag[] inlineTags() { - return Util.inlineTags(doc(), text(), locale(), err()); //doc()); - } - - /** - * Returns the first sentence tags in this tag. - * - * @return an array of Tag representing the first sentence - * tags in this tag. - * @see Util#firstSentenceTags - */ - public Tag[] firstSentenceTags() { - return Util.firstSentenceTags(doc(), text(), locale(), err()); - } - - -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/ThrowsTagImpl.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/ThrowsTagImpl.java deleted file mode 100644 index f6ade10e7..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/ThrowsTagImpl.java +++ /dev/null @@ -1,104 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.ajdoc; - -import com.sun.javadoc.ClassDoc; -import com.sun.javadoc.Doc; -import com.sun.javadoc.ThrowsTag; - -import java.util.Locale; - -/** - * Represents a throws tag in the aspectj-world. - * - * @author Jeff Palm - */ -public class ThrowsTagImpl extends TagImpl implements ThrowsTag { - - private ClassDoc exception; - private String exceptionComment; - private String exceptionName; - - /** - * Constructs the new tag with given parameters and - * splits the text. - * - * @param doc the new value for doc. - * @param name the new value for name. - * @param text the new value for text. - * @param locale the new value for locale. - * @param err the new value for err. - */ - public ThrowsTagImpl(Doc doc, - String name, - String text, - Locale loc, - ErrPrinter err) { - super(doc, name, text, loc, err); - String[] split = split(text); - exceptionName = split[0]; - exceptionComment = split[1]; - exception = findException(); - } - - /** - * Returns the exception thrown. - * - * @return a ClassDoc that represents the thrown exception. - */ - public ClassDoc exception() { - return exception; - } - - /** - * Returns the comment text. - * - * @return a String of the comment text. - */ - public String exceptionComment() { - return exceptionComment; - } - - /** - * Returns the name of the type of exception thrown. - * - * @return a String name of the type of exception thrown. - */ - public String exceptionName() { - return exceptionName; - } - - /** - * Returns throws. - * - * @return throws. - */ - public String kind() { - return "@throws"; - } - - //XXX - //TODO: implement FUUUUUUCCCCCCCCCKKKKKKKKKKKK - private ClassDoc findException() { - return null; - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/TypeImpl.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/TypeImpl.java deleted file mode 100644 index 683848c42..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/TypeImpl.java +++ /dev/null @@ -1,165 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.ajdoc; - -import org.aspectj.compiler.base.ast.ArrayType; -import org.aspectj.compiler.base.ast.NameType; -import org.aspectj.compiler.base.ast.PrimitiveType; -import org.aspectj.compiler.base.ast.Type; - -import com.sun.javadoc.ClassDoc; - -public class TypeImpl { //implements org.aspectj.ajdoc.Type { - - public static com.sun.javadoc.Type getInstance(Type type) { - return factory.getInstance(type); - } - - public static com.sun.javadoc.Type getInstance(String spec, - ClassDoc where) { - return factory.getInstance(spec, where); - } - - private final static class Primitive implements org.aspectj.ajdoc.Type { - - - - public final static Primitive getInstance(PrimitiveType type) { - return getInstance(type.getName()); - } - - public final static Primitive getInstance(String name) { - if ("void".equals(name)) return voidType; - if ("boolean".equals(name)) return booleanType; - if ("byte".equals(name)) return byteType; - if ("char".equals(name)) return charType; - if ("short".equals(name)) return shortType; - if ("int".equals(name)) return intType; - if ("long".equals(name)) return longType; - if ("float".equals(name)) return floatType; - if ("double".equals(name)) return doubleType; - return null; - } - - public final static boolean isPrimitive(String name) { - return name.equals("boolean") - || name.equals("byte") - || name.equals("char") - || name.equals("short") - || name.equals("int") - || name.equals("long") - || name.equals("float") - || name.equals("double"); - } - - private final String name; - private Primitive(String name) { this.name = name; } - - public String toString() { return name; } - public String typeName() { return name; } - public String qualifiedTypeName() { return name; } - public String dimension() { return ""; } - public ClassDoc asClassDoc() { return null; } - - private final static Primitive voidType = new Primitive("void"); - private final static Primitive booleanType = new Primitive("boolean"); - private final static Primitive byteType = new Primitive("byte"); - private final static Primitive charType = new Primitive("char"); - private final static Primitive shortType = new Primitive("short"); - private final static Primitive intType = new Primitive("int"); - private final static Primitive longType = new Primitive("long"); - private final static Primitive floatType = new Primitive("float"); - private final static Primitive doubleType = new Primitive("double"); - } - - private final static class Array implements org.aspectj.ajdoc.Type { - protected final com.sun.javadoc.Type type; - protected final int dimension; - private Array(com.sun.javadoc.Type type, int dimension) { - this.type = type; - //TODO: tune this later - this.dimension = dimension; - } - - public String toString() { return type.toString(); } - public String typeName() { return type.typeName(); } - public String qualifiedTypeName() { return type.qualifiedTypeName(); } - public ClassDoc asClassDoc() { return type.asClassDoc(); } - public String dimension() { - String str = ""; - for (int i = 0; i < dimension; i++) str += "[]"; - return str; - } - - public boolean equals(Object other) { - if (!(other instanceof Array)) { - return super.equals(other); - } - Array array = (Array)other; - return array.type.equals(type) - && array.dimension == dimension; - } - } - - - private static final Factory factory = new Factory(); - private final static class Factory { - - private com.sun.javadoc.Type getInstance(Type type) { - if (type instanceof PrimitiveType) { - return Primitive.getInstance((PrimitiveType)type); - } else if (type instanceof ArrayType) { - ArrayType arrayType = (ArrayType)type; - Type component = arrayType.getComponentType(); - while (component instanceof ArrayType) { - component = ((ArrayType)component).getComponentType(); - } - return new Array(getInstance(component), - arrayType.getArrayDimCount()); - } else { - return ClassDocImpl.getInstance(((NameType)type).getTypeDec()); - } - } - - private com.sun.javadoc.Type getInstance(String spec, - ClassDoc where) { - int ibracket = spec.indexOf('['); - String name; - int dimension; - if (ibracket != -1) { - name = spec.substring(0, ibracket); - dimension = spec.substring(ibracket+1).length()/2; - } else { - name = spec; - dimension = 0; - } - com.sun.javadoc.Type type = Primitive.getInstance(name); - if (type == null) { - type = where.findClass(name); //TODO - } - if (dimension > 0) { - type = new Array(type, dimension); - } - return type; - } - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/Util.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/Util.java deleted file mode 100644 index eaf7fda59..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/Util.java +++ /dev/null @@ -1,933 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.ajdoc; - -import org.aspectj.compiler.base.ast.Constructor; -import org.aspectj.compiler.base.ast.ConstructorDec; -import org.aspectj.compiler.base.ast.Exprs; -import org.aspectj.compiler.base.ast.Field; -import org.aspectj.compiler.base.ast.FieldDec; -import org.aspectj.compiler.base.ast.Formals; -import org.aspectj.compiler.base.ast.Method; -import org.aspectj.compiler.base.ast.MethodDec; -import org.aspectj.compiler.base.ast.NameType; -import org.aspectj.compiler.base.ast.Type; -import org.aspectj.compiler.base.ast.TypeDec; -import org.aspectj.compiler.crosscuts.ast.PointcutDec; -import org.aspectj.compiler.crosscuts.ast.PointcutSO; - -import com.sun.javadoc.Doc; -import com.sun.javadoc.ExecutableMemberDoc; -import com.sun.javadoc.MemberDoc; -import com.sun.javadoc.Parameter; -import com.sun.javadoc.Tag; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.StringTokenizer; - -/** - * A utility class used by lots of folks. - * - * @author Jeff Palm - */ -public class Util { - - /** - * Delegate to Character.isJavaIdentifierStart(char). - * - * @return true if c can - * start a java identifier. - */ - public final static boolean start(char c) { - return Character.isJavaIdentifierStart(c); - } - - /** - * Delegate to Character.isJavaIdentifierPart(char). - * - * @return true if c can - * be a part of a java identifier. - */ - public final static boolean ident(char c) { - return Character.isJavaIdentifierPart(c); - } - - /** - * Delegate to Character.isWhitespace(char). - * - * @return true if c is - * valid white space. - */ - public final static boolean space(char c) { - return Character.isWhitespace(c); - } - - /** - * Returns true is c is a newline character. - * - * @return true if - * c == '\n' || c == '\r'. - */ - public final static boolean newline(char c) { - return c == '\n' || c == '\r'; - } - - /** - * Returns two strings split at the first white space. - * - * @return an array of two Strings split at - * the first white space. - */ - public static String[] split(String str) { - String[] strs = new String[2]; - for (int i = 0; i < str.length(); i++) { - if (space(str.charAt(i))) { - strs[0] = str.substring(0, i); - strs[1] = str.substring(i+1); - break; - } - } - if (strs[0] == null) { - strs[0] = str; - strs[1] = ""; - } - return strs; - } - - /** - * Returns the inline tags found in str. - * - * @param doc Doc to give to the new tag. - * @param str String from which to create the tags. - * @param loc Locale to give to the new tag. - * @param err ErrPrinter to give to the new tag. - * @return an array of Tag representing the inline - * tags found in str. - */ - public final static Tag[] inlineTags(Doc doc, - String str, - Locale loc, - ErrPrinter err) { - if (str == null || str.length() < 1) { - return new Tag[0]; - } - - int N = str.length(); - - List list = new ArrayList(); - - int i = 0; - for (int j = i; i < N; j = i) { - - // Try to match a link tag - int ileft = str.indexOf("{@", i); - - // If there are no more link tags, return the rest - // of str as a 'Text' Tag - if (ileft == -1) { - list.add(new TagImpl(doc, "Text", - str.substring(i), - loc, err)); - break; - } - - if (j < ileft) { - list.add(new TagImpl(doc, "Text", - str.substring(j, ileft), - loc, err)); - } - - // If there is a tag and it's name is 'link ' try to - // match it - i = ileft; - if (i+7 < N && - str.substring(i+2, i+7).toLowerCase().equals("link ")) { - i += 7; - for (; str.charAt(i) != '}'; i++) { - if (i == N-1) { - err.error("tag_unterminated_link_tag", - str.substring(i)); - break; - } - } - list.add(new SeeTagImpl(doc, "@link", - str.substring(ileft+7, i), - loc, err)); - } else { - err.error("tag_invalid_link_tag", - str.substring(i)); - } - - // Don't want to include the right brace - i += 1; - } - return (Tag[])list.toArray(new Tag[list.size()]); - } - - /** - * Returns the first sentence tags found in str. - * - * @param doc Doc to give to the new tag. - * @param str String from which to create the tags. - * @param loc Locale to give to the new tag. - * @param err ErrPrinter to give to the new tag. - * @return an array of Tag representing the first - * sentence tags found in str. - */ - public final static Tag[] firstSentenceTags(Doc doc, - String str, - Locale loc, - ErrPrinter err) { - return inlineTags(doc, firstSentenceText(str, loc, err), loc, err); - } - - /** - * Returns the first sentence tags found in str, - * using Locale.US as the default locale. - * - * @param doc Doc to give to the new tag. - * @param str String from which to create the tags. - * @param err ErrPrinter to give to the new tag. - * @return an array of Tag representing the first - * sentence tags found in str. - */ - private static String firstSentenceText(String str, - Locale loc, - ErrPrinter err) { - if (str == null || loc == null || !loc.equals(Locale.US)) { - return ""; - } - final int N = str.length(); - int i; - for (i = 0; i < N; i++) { - - // A period at the end of the text or a - // period followed by white space is the - // end of a sentence - if (str.charAt(i) == '.') { - if (i == N-1) { - return str.substring(0, i+1); - } - if (space(str.charAt(i+1))) { - return str.substring(0, i+2); - } - } - - // An HTML tag the signals the end -- one of: - //

- //


 or 
- if (str.charAt(i) == '<') { - int j = i+1; - - // Find the closing '>' - while (j < N && str.charAt(j) != '>') j++; - - // If there's no closing '>' signal an error - if (j == N) { - err.error("unterminated_html_tag", str); - return str; - } - - // Inspect the inside of the tag - String innards = str.substring(i+1, j).trim().toLowerCase(); - if (innards.equals("p") || innards.equals("pre") || - innards.equals("h1") || innards.equals("h2") || - innards.equals("h3") || innards.equals("h4") || - innards.equals("h5") || innards.equals("h6") || - innards.equals("hr")) { - return str.substring(0, i+1); - } - } - } - return str; - } - - /** - * Returns the tags found in str. - * - * @param doc Doc to give to the new tag. - * @param str String from which to create the tags. - * @param loc Locale to give to the new tag. - * @param err ErrPrinter to give to the new tag. - * @return an array of Tag representing the - * tags found in str. - */ - public final static List findTags(Doc doc, - String str, - Locale loc, - ErrPrinter err) { - - //XXX This sucks!!! Will redo later. - boolean newline = true; - List result = new ArrayList(); - if (str == null) return result; - final int N = str.length(); - int lastTag = -1; - for (int i = 0; i < N; i++) { - if (newline(str.charAt(i))) { - newline = true; - // XXX need to evaluate - some tags can span newlines? -// if (lastTag != -1) { // now requiring tags not to span newlines -// result.add(parse(doc, str.substring(lastTag, i), -// loc, err)); -// } -// lastTag = -1 - } else if (space(str.charAt(i)) && newline) { - } else if (str.charAt(i) == '@' && newline) { - if (lastTag != -1) { - result.add(parse(doc, str.substring(lastTag, i), - loc, err)); - } - lastTag = i; - } else { - newline = false; - } - } - if (lastTag != -1) { - result.add(parse(doc, str.substring(lastTag), - loc, err)); - } - return result; - } - - private final static Tag parse(Doc doc, - String str, - Locale loc, - ErrPrinter err) { - Tag result = null; - String[] split = split(str); - String name = split[0]; - String rest = split[1]; - if (name.equals("@see")) { - result = new SeeTagImpl(doc, name, rest, loc, err); - } else if (name.equals("@exception") || name.equals("@throws")) { - result = new ThrowsTagImpl(doc, name, rest, loc, err); - } else if (name.equals("@serialField")) { - result = new SerialFieldTagImpl(doc, name, rest, loc, err); - } else if (name.equals("@param")) { - result = new ParamTagImpl(doc, name, rest, loc, err); - } else { - result = new TagImpl(doc, name, rest, loc, err); - } - return result; - } - - /** - * Returns the raw comment text found in str. - * - * @param str String containing comment from which - * the raw comment is found. - * @return String with the raw comment taken - * from str. - */ - public final static String rawCommentText(String str) { - if (str == null) return ""; - if (str.length() < 3) return ""; - String withstars = ""; - int islash = str.indexOf('/'); - if (islash == -1 || islash+2 >= str.length()) { - return ""; - } - if (str.charAt(islash+1) != '*' || - str.charAt(islash+2) != '*') { - return ""; - } - int start = islash+2+1; - while (str.charAt(start) == '*' || space(str.charAt(start))) start++; - int end = str.length()-2; - while (str.charAt(end) == '*') end--; - if (start != -1 && end > start) { - withstars = str.substring(start, end+1); - } - //String result = ""; - StringBuffer result = new StringBuffer(withstars.length()); - for (StringTokenizer t = new StringTokenizer(withstars, "\n", true); - t.hasMoreTokens();) { - String line = t.nextToken(); - if (line == null || line.length() == 0) continue; - int i; - for (i = 0; i < line.length(); i++) { - if (!(line.charAt(i) == '*' || - line.charAt(i) == ' ')) { - break; - } - } - //result += line.substring(i); - result.append(line.substring(i)); - } - //return result; - return result.toString(); - } - - /** - * Returns the comment text from the passed in - * raw comment text -- e.g. no tags at the end. - * - * @param rawCommentText raw comment text to search. - * @return the comment text from - * rawCommentText. - */ - public final static String commentText(String rawCommentText) { - //String result = ""; - if (rawCommentText == null) { - return ""; - } - StringBuffer result = new StringBuffer(rawCommentText.length()); - outer: - for (StringTokenizer t = new StringTokenizer(rawCommentText, "\n", true); - t.hasMoreTokens();) { - String line = t.nextToken(); - if (line == null || line.length() == 0) continue; - int i; - for (i = 0; i < line.length(); i++) { - char c = line.charAt(i); - if (c == ' ' || c == '\t') { - } else if (c == '@') { - break outer; - } else { - //result += line; - result.append(line); - continue outer; - } - } - } - //return result; - return result.toString(); - } - - /** - * Compares using names. - * - * @param $ First Doc. - * @param _ Second Doc. - * @return -1 if either are null, else - * $.name.compareTo(_.name. - */ - public final static int compareTo(Doc $, Doc _) { - return ($ == null || _ == null) ? -1 : $.name().compareTo(_.name()); - } - - /** - * Returns the signature, given parameters, - * without flattening. - * - * @param parameters an array of Parameter. - * @return String representation of the parameters. - * @see #signature(Parameter[],boolean) - */ - public final static String signature(Parameter[] parameters) { - return signature(parameters, false); - } - - /** - * Returns the signature, given parameters, - * with flattening. - * - * @param parameters an array of Parameter. - * @return String representation of the parameters. - * @see #signature(Parameter[],boolean) - */ - public final static String flatSignature(Parameter[] parameters) { - return signature(parameters, true); - } - - /** - * Returns the signature, given parameters - * and flattens if flatten. - * - * @param parameters an array of Parameter. - * @param flatten true if the parameter names - * should be flattened. - * @return String representation of the parameters. - */ - public final static String signature(Parameter[] parameters, - boolean flatten) { - if (parameters == null || parameters.length == 0) { - return "()"; - } - //String str = "("; - StringBuffer str = new StringBuffer((flatten ? 8 : 20) * - parameters.length); - str.append("("); - final int N = parameters.length; - for (int i = 0; i < N; i++) { - String typeName = parameters[i].typeName(); - if (flatten) { - int idot = typeName.lastIndexOf('.'); - if (idot != -1) { - typeName = typeName.substring(idot+1); - } - } - //str += typeName + (i < N-1 ? "," : ""); - str.append(typeName + (i < N-1 ? "," : "")); - - } - //str += ")"; - str.append(")"); - //return str; - return str.toString(); - } - - /** - * Returns true -- include all members for now. - * - * @param doc member to consider. - * @param flags access flags. - */ - public final static boolean isIncluded(MemberDoc doc, long flags) { - return true; - } - - /** - * Returns true if dec - * isn't local or annonymous or null. - * - * @param dec TypeDec to consider. - * @return true isn't dec is local or - * annonymous or null. - */ - public final static boolean isIncluded(TypeDec dec) { - if (dec == null) { - return false; - } - if (dec.isLocal() && dec.isAnonymous()) { - return false; - } - return true; //XXX to do - } - - //XXX Debugging - public final static void dump(Object o, String prefix) { - System.err.println(">> Dumping:"+o); - java.lang.reflect.Method[] ms = o.getClass().getMethods(); - List list = new ArrayList(); - for (int i = 0; i < ms.length; i++) { - list.add(ms[i]); - } - Collections.sort(list, new Comparator() { - public int compare(Object o1, Object o2) { - return str(o1).compareTo(str(o2)); - } - public boolean equals(Object o1, Object o2) { - return str(o1).equals(str(o2)); - } - private String str(Object _) { - return (_ != null && _ instanceof java.lang.reflect.Method) - ? ((java.lang.reflect.Method)_).getName() : _+""; - } - }); - for (Iterator i = list.iterator(); i.hasNext();) { - java.lang.reflect.Method m = (java.lang.reflect.Method)i.next(); - if (m.getParameterTypes().length == 0 && - m.getName().startsWith(prefix)) { - try { - System.err.println(" "+m.getName()+":"+ - m.invoke(o, new Object[0])); - } catch (Throwable _) {} - } - } - } - public final static void gets(Object o) { - dump(o, "get"); - } - public final static void array(Object[] os) { - array(os, false); - } - public final static void array(Object[] os, boolean gets) { - if (os == null) { - System.err.println("NULL"); - return; - } - System.err.println(os.getClass().getName()+":" + os.length); - for (int i = 0; i < os.length; i++) { - System.err.println(" [" + i +"]:" + os[i]); - if (gets) gets(os[i]); - } - } - - /** - * Returns the HTML documentation found in html - * using err to report errors. - * - * @param html File in which to look. - * @param err ErrPrinter to use to report errors. - * @return HTML documentaiton found in html. - */ - public static String documentation(File html, ErrPrinter err) { - String str = ""; - InputStream in = null; - try { - in = new FileInputStream(html); - } catch (IOException ioe) { - err.ex(ioe, "ioexception_open", html.getAbsolutePath()); - return ""; - } - try { - byte[] bytes = new byte[in.available()]; - in.read(bytes, 0, bytes.length); - in.close(); - str = new String(bytes); - } catch (IOException ioe) { - err.ex(ioe, "ioexception_reading", html.getAbsolutePath()); - } - - int[] is = new int[]{-10,-1}; - int i = 0; - final char[] chars = new char[]{'/','B','O','D','Y','>'}; - for (int j = 1; j >= 0; j--) { - nextTag: - for (; i != -1; i = str.indexOf('<', i+1)) { - nextLt: - for (int s = i+1, k = j; s < str.length(); s++, k++) { - char c = str.charAt(s); - if (k == chars.length) { - is[j] += s+2; - break nextTag; - } - if (!(c == chars[k] || c == (chars[k] | 0x01000000))) { - break nextLt; - } - } - } - } - if (is[0] > -1 && is[1] > -1) { - str = str.substring(is[1], is[0]); - } - return str; - } - - /** - * Returns the result of invoking the method name - * on target with parameters params - * declared in the target's class using arguments - * args. - * - * @param target target Object. - * @param name name of the method. - * @param params array of Class of parameters of the method. - * @param args array of Object of arguments to the method. - * @return the result of invoking the method. - * @see #invoke(Class,Object,String,Class[],Object[]) - */ - public static Object invoke(Object target, String name, - Class[] params, Object[] args) { - return invoke(target.getClass(), target, name, params, args); - } - - /** - * Returns the result of invoking the method name - * on target with parameters params - * declared in the type using arguments - * args. - * This method handles any errors that arise in doing so. - * - * @param type type in which the method is declared. - * @param target target Object -- null for static methods. - * @param name name of the method. - * @param params array of Class of parameters of the method. - * @param args array of Object of arguments to the method. - * @return the result of invoking the method. - */ - public static Object invoke(Class type, Object target, String name, - Class[] params, Object[] args) { - try { - java.lang.reflect.Method method = type.getDeclaredMethod(name, params); - method.setAccessible(true); - return method.invoke(target, args); - } catch (Exception e) { - e.printStackTrace(); //TODO - } - return null; - } - - /** - * Returns the value of access the field name - * declared in type on target. - * This method handles any errors that arise in doing so. - * - * @param type type in which the field is declared. - * @param target target that is currently holding the field -- - * null for static fields. - * @param name name of the field. - * @return the result of accessing this field. - */ - public static Object access(Class type, Object target, String name) { - try { - java.lang.reflect.Field field = type.getDeclaredField(name); - field.setAccessible(true); - return field.get(target); - } catch (Exception e) { //TODO - e.printStackTrace(); - } - return null; - } - - /** - * Returns the ExecutableMemberDoc from the array passed - * in whose parameters weakly match those of - * params and whose name matches exactly - * with name. - * This method can return null. - * - * @param emds an array of ExecutableMemberDoc from which - * the returned value comes. - * @param name the name of the member to return. - * @param params an array of Parameter that represent - * the parameters we're trying to match. - * @return an ExecutableMemberDoc whose parameters - * match the names and order found in - * params and whose name - * exactly equals name. - */ - public final static ExecutableMemberDoc executableMemberDoc - (ExecutableMemberDoc[] emds, - String name, - Parameter[] params) { - ExecutableMemberDoc result = null; - next: - for (int i = 0; i < emds.length; i++) { - ExecutableMemberDoc emd = emds[i]; - if (emd.name().equals(name) && - params.length == emd.parameters().length) { - for (int j = 0; j < params.length; j++) { - if (!params[j].typeName().equals - (emd.parameters()[j].typeName())) { - continue next; - } - result = emd; - break next; - } - } - } - return result; - } - - /** - * Returns the PointcutDoc from the array passed - * in whose parameters weakly match those of - * formals and whose name matches exactly - * with id. - * This method can return null. - * - * @param nameType the type in which we're searching. - * @param id the name of the pointcut to return. - * @param formals the Formals whose name and order - * must match to return a pointcut. - * @return a PointcutDoc whose parameters - * match the names and order found in - * formals and whose name - * exactly equals id. - */ - public final static PointcutDec pointcutDec(NameType nameType, - String id, - Formals formals) { - PointcutDec result = null; - next: - for (Iterator i = nameType.getPointcuts().iterator(); i.hasNext();) { - PointcutDec md = ((PointcutSO)i.next()).getPointcutDec(); - if (md.getFormals().size() == formals.size() && - id.equals(md.getId())) { - for (int j = 0; j < formals.size(); j++) { - if (!md.getFormals().get(j).getType().getString(). - equals(formals.get(j).getType().getString())) { - continue next; - } - } - result = md; - break next; - } - } - return result; - } - - - - /** - * Returns the MethodDoc from the array passed - * in whose parameters weakly match those of - * formals and whose name matches exactly - * with id. - * This method can return null. - * - * @param nameType the type in which we're searching. - * @param id the name of the method to return. - * @param formals the Formals whose name and order - * must match to return a method. - * @return a MethodDoc whose parameters - * match the names and order found in - * formals and whose name - * exactly equals id. - */ - public final static MethodDec methodDec(NameType nameType, - String id, - Formals formals) { - MethodDec result = null; - next: - for (Iterator i = nameType.getMethods().iterator(); i.hasNext();) { - //MethodDec md = (MethodDec)i.next(); - MethodDec md = ((Method)i.next()).getMethodDec(); - if (md.getFormals().size() == formals.size() && - id.equals(md.getId())) { - for (int j = 0; j < formals.size(); j++) { - if (!md.getFormals().get(j).getType().getString(). - equals(formals.get(j).getType().getString())) { - continue next; - } - } - result = md; - break next; - } - } - return result; - } - - /** - * Returns the PointcutDec named name, - * contained in typeDec with type type. - * showError is passed to subsequent methods - * to supress or warrant error printing. - * This may return null. - * - * @param type Type in which this pointcut was declared. - * @param name name of the pointcut. - * @param typeDec TypeDec in which we're searching. - * @param showError true is an error should - * be printed upon not finding a pointcut. - * @return the pointcut declared in type - * named name, found by searching - * from typeDec. This may be - * null. - */ - public static PointcutDec getPointcutDec(Type type, - String name, - TypeDec typeDec, - boolean showError) { - PointcutSO so = ((NameType)type).getPointcut(name, typeDec, showError); - PointcutDec dec = null; - if (so != null) { - dec = (PointcutDec)so.getCorrespondingDec(); - } - return dec; - } - - /** - * Returns the FieldDec named name, - * contained in typeDec with type type. - * showError is passed to subsequent methods - * to supress or warrant error printing. - * This may return null. - * - * @param type Type in which this field was declared. - * @param name name of the field. - * @param typeDec TypeDec in which we're searching. - * @param showError true is an error should - * be printed upon not finding a field. - * @return the field declared in type - * named name, found by searching - * from typeDec. This may be - * null. - */ - public static FieldDec getFieldDec(Type type, - String name, - TypeDec typeDec, - boolean showError) { - Field so = ((NameType)type).getField(name, typeDec, showError); - FieldDec dec = null; - if (so != null) { - dec = (FieldDec)so.getCorrespondingDec(); - } - return dec; - } - - /** - * Returns the MethodDec named name, with - * formals params, - * contained in typeDec with type type. - * showError is passed to subsequent methods - * to supress or warrant error printing. - * This may return null. - * - * @param type Type in which this method was declared. - * @param name name of the method. - * @param typeDec TypeDec in which we're searching. - * @param params the method's formal parameters. - * @param showError true is an error should - * be printed upon not finding a method. - * @return the method declared in type - * named name, found by searching - * from typeDec. This may be - * null. - */ - public static MethodDec getMethodDec(Type type, - String name, - TypeDec typeDec, - Exprs params, - boolean showError) { - Method so = ((NameType)type).getMethod(name, typeDec, params, showError); - MethodDec dec = null; - if (so != null) { - dec = so.getMethodDec(); - } - return dec; - } - - /** - * Returns the ConstructorDec named name, with - * formals params, - * contained in typeDec with type type. - * showError is passed to subsequent constructors - * to supress or warrant error printing. - * This may return null. - * - * @param type Type in which this constructor was declared. - * @param name name of the constructor. - * @param typeDec TypeDec in which we're searching. - * @param params the constructor's formal parameters. - * @param showError true is an error should - * be printed upon not finding a constructor. - * @return the constructor declared in type - * named name, found by searching - * from typeDec. This may be - * null. - */ - public static ConstructorDec getConstructorDec(Type type, - TypeDec typeDec, - Exprs params, - boolean showError) { - Constructor so = ((NameType)type).getConstructor(typeDec, - params, showError); - ConstructorDec dec = null; - if (so != null) { - dec = (ConstructorDec)so.getCorrespondingDec(); - } - return dec; - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/resources/ajdoc.properties b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/resources/ajdoc.properties deleted file mode 100644 index e1c0a4b96..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/resources/ajdoc.properties +++ /dev/null @@ -1,77 +0,0 @@ -usage_help=usage\: {0} [options] [packagenames] [sourcefiles] [classnames] [@files]\n-overview Read overview documentation from HTML file\n-public Show only public classes and members\n-protected Show protected/public classes and members (default)\n-package Show package/protected/public classes and members\n-private Show all classes and members\n-help Display command line options\n-doclet Generate output via alternate doclet (unsupported)\n-docletpath Specify where to find doclet class files (unsupported)\n-sourcepath Specify where to find source files\n-classpath Specify where to find user class files\n-bootclasspath Override location of class files loaded\n by the bootstrap class loader \n-source 1.4 Provide source compatibility with Java 1.4 \n-extdirs Override location of installed extensions\n-verbose Output messages about what AJDoc is doing\n-locale Locale to be used, e.g. en_US or en_US_WIN\n-encoding Source file encoding name\n-standard Use com.sun.tools.doclets.standard.Standard doclet\n-log Log each pass of document generation\n-argfile The file contains a line-delimited list of files\n inserted into the argument list\n-compiler Generate RootDoc to doclet via alternate compiler (unsupported) -\n-J Pass directly to the runtime system\n - -internal_error=Internal error\: {0} -file_not_found_exception:Cannot read file\: {0}. -io_exception:IOException\: {0}. -argument_already_seen=The {0} option may be specified no more than once. -invalid_flag=invalid flag\: {0}. -requires_argument=option {0} requires {1} argument(s). -cant_create_root_doc=Cannot create RootDoc from class {0}. -cant_create_root_doc_ex=Cannot create RootDoc from class {0}\: {1}. -incorrect_root_doc_class=The class {0} must implement the interface org.aspectj.tools.javadoc.RootDocMaker, not {1}. -root_doc_maker_is_null=Could not create RootDocMaker from class {0}. -done_in=[done in {0} ms] -internal_error_exception_thrown=Internal error\: In class {0}, method {1} has thrown an exception: {2}. -method_not_accessible=In class {0}, method {1} not accessible. -class_not_found=Cannot find {0} class {1}. -invoke_exception_thrown=Could not invoke method {0} in class {1}. -must_return=In class {0}, method {1} must return {2}, not {3}. -doclet_method_not_found=Doclet class {0} does not contain a {1} method. -doclet_method_not_accessible=In doclet class {0}, method {1} not accessible. -doclet_method_must_be_static=In doclet class {0}, method {1} must be static. -out_of_memory=java.lang.OutOfMemoryError\: Please increase memory.\nFor example, on the Sun Classic or HotSpot VMs, add the option -J-Xmx\nsuch as -J-Xmx32m. -exception_thrown=In {0} class {1}, method {2} has thrown an exception\: {3} -No_packages_or_classes_specified=No packages or classes specified. -cant_create_doclet:Cannot create Doclet from class {0} - -method_not_found={0} class {1} does not contain a {2} method. -method_not_accessible=In {0} class {1}, method {2} not accessible. -must_have_default_ctor=Class {0} must contain a default, no-arguments constructor. -class_cast_exception:Return type of method {0} in class {1} must be {2}, not {3} -cant_construct_object=Cannot construct object of type {0} -unsupported_version=The version {0} is currently not supported by {1}. - -see_tag_prematurely_done=Prematurely done reading - not finished\: {0} -see_tag_unterminated_url=Unterminated see tag URL\: {0} -see_tag_unterminated_string=Unterminated see tag string\: {0} -see_tag_invalid_package_or_class=Invalid package or class in see tag\:{0}\: {1} -see_tag_invalid_field_name=Invalid field name in see tag\:{0}\: {1} -see_tag_invalid_param_start=Invalid parameter start in see tag\:{0}\: {1} -see_tag_premature_param_end=Premature end of parameters in see tag\:{0}\: {1} -see_tag_invalid_id=Invalid identifier in see tag\:{0}\: {1} -see_tag_invalid_parameter_type=Invalid parameter type in see tag {0}\: {1} -see_tag_invalid_parameter_type=Invalid parameter type in see tag {0}\: {1} -see_tag_invalid_parameter_type_lbrace=Invalid parameter type in see tag, looking for left brace {0}\: {1} -see_tag_invalid_parameter_type_ident=Invalid parameter type in see tag, looking for identifier {0}\: {1} -see_tag_unterminated_array_type=Unterminated array type in see tag\: {0} -see_tag_invalid_parameter_name=Invalid parameter name in see tag\: {0} -see_tag_invalid_parameters=Invalid paramters in see tag\: {0} -see_tag_expecting_typename_or_whitespace:Expecting type name or white space in see tag\: {0} -see_tag_expecting_field_name:Expecting field name after # in see tag\: {0} -see_tag_dot_sharp_or_id:Expecting '\#', ., or identifier in see set\: {0} -tag_invalid_link_tag=Invalid link tag\: {0} -tag_unterminated_link_tag=Unterminated link tag\: {0} -serialField_tag_invalid_field_name_start=Invalid start of a field name in serialField tag\: '{0}' -serialField_tag_invalid_field_name_part=Invalid part of a field name in serialField tag\: '{0}' -serialField_tag_invalid_type_name_start=Invalid start of a type name in serialField tag\: '{0}' -serialField_tag_invalid_type_name_part=Invalid part of a type name in serialField tag\: '{0}' -unterminated_html_tag=Unterminated HTML tag\: {0} -Loading_source_file=Loading source file {0}... -Loading_source_file_for_class=Loading source file for class {0}... -Loading_source_files_for_package=Loading source files for package {0}... -ioexception_open=Trouble openning file {0} -ioexception_close=Trouble closing file {0} -ioexception_reading=Trouble reading from file {0} -cant_resolve_file=Cannot resolve file {0} -file_doesnt_exist=The file {0} does not exist -invalid_package_name:Invalid package name: {0} -internal_msg=Please copy the following text into an email message and send it,\n\ -along with any additional information you can add to: \n\ - \n\ - support@aspectj.org \n\ - -starting_internal_compile=Starting compile... -initializing_world=Initializing world... -creating_root=Creating root... -generating_docs=Generating documentation... diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/rootmakers/Javadoc.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/rootmakers/Javadoc.java deleted file mode 100644 index 75d351904..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/rootmakers/Javadoc.java +++ /dev/null @@ -1,151 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.ajdoc.rootmakers; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import org.aspectj.tools.ajdoc.ErrPrinter; - -/** - * An abstract class for a javadoc rootmaker. - * Provides some error handling and misc. functionality. - * - * @author Jeff Palm - */ -public abstract class Javadoc { - - /** Subclasses may want this ;). */ - protected ErrPrinter err; - - /** Default ctor. */ - public Javadoc() {} - - - /** - * Returns the result of invoking method, - * on target owner, with arguments args. - * This method handles errors that arise. - * - * @param method method to invoke. - * @param owner target of the invocation. - * @param args arguments to pass the method. - * @return result of invoking the method on - * the passed in owner with the passed in - * parameters. - */ - protected final Object invoke(Method method, Object owner, Object[] args) { - if (method == null || owner == null) return null; - String classname = owner.getClass().getName(); - String methodName = method.getName(); - try { - Thread.currentThread().setContextClassLoader - (owner.getClass().getClassLoader()); - return method.invoke(owner, args); - } catch (InvocationTargetException e) { - err.invocationTargetException(e, classname, methodName); - } catch (IllegalAccessException e) { - err.ex(e, "method_not_accessible", classname, methodName); - } catch (Exception e) { - err.ex(e, "exception_thrown", "List", - classname, methodName, e != null ? e.getMessage() : e+""); - } - return null; - } - - /** - * Returns the Class with name classname. - * This may return null if Class.forName returns null, - * but otherwise, this method handles resulting errors. - * - * @param classname name of the class to get. - * @return Class named clasname. - */ - protected final Class type(String classname) { - try { - return Class.forName(classname); - } catch (ClassNotFoundException e) { - err.ex(e, "class_not_found", "Hashtable", classname); - } - return null; - } - - /** - * Returns the method named name, whose parameters - * are declared params, and which is declared - * in type. - * - * @param name name of the method. - * @param params type of the parameters. - * @param type type in which the resulting method is declared. - * @return the method named name, whose parameters - * are declared params, and which is declared - * in type. This may be null. - */ - protected final Method method(String name, Class[] params, Class type) { - if (type == null) return null; - try { - return type.getMethod(name, params); - } catch (NoSuchMethodException e) { - err.ex(e, "method_not_found", type.getClass().getName(), name); - } - return null; - } - - /** - * Returns the Object resulting from default construction - * of a class named classname. This method - * handles all errors that arise. - * - * @param classname class name of the resulting Object. - * @return new instance made from the default - * construction of a class named - * classname. This may be null. - * @see #newInstance(Class) - */ - protected final Object newInstance(String classname) { - return newInstance(type(classname)); - } - - /** - * Returns the Object resulting from default construction - * of a class type. This method - * handles all errors that arise. - * - * @param type Class of the resulting Object. - * @return new instance made from the default - * construction of a class named - * classname. This may be null. - */ - protected final Object newInstance(Class type) { - if (type == null) return null; - try { - return type.newInstance(); - } catch (InstantiationException e) { - err.ex(e, "must_have_default_ctor", type.getClass().getName()); - return null; - } catch (IllegalAccessException e) { - err.ex(e, "method_not_accessible", type.getClass().getName(), "new()"); - return null; - } - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/rootmakers/Javadoc13.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/rootmakers/Javadoc13.java deleted file mode 100644 index a8a3cdf3a..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/rootmakers/Javadoc13.java +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.ajdoc.rootmakers; - -import com.sun.javadoc.RootDoc; -import com.sun.javadoc.DocErrorReporter; -import java.lang.reflect.Method; -import java.util.List; -import org.aspectj.tools.ajdoc.AccessChecker; -import org.aspectj.tools.ajdoc.RootDocMaker; -import org.aspectj.tools.ajdoc.CannotMakeRootDocException; - -/** - * Makes a RootDoc using javadoc from SDK 1.3 as an example. - * - * @author Jeff Palm - */ -public class Javadoc13 extends Javadoc implements RootDocMaker { - - public Javadoc13() {} - public RootDoc makeRootDoc(String sourcepath, - String classpath, - String bootclasspath, - String extdirs, - long flags, - String encoding, - String locale, - String source, - List classesAndPackages, - List options, - DocErrorReporter messager, - String programName, - AccessChecker filter) - throws CannotMakeRootDocException { - // todo: options ignored in 13? - Class envClass = type("com.sun.tools.javadoc.Env"); - if (envClass == null) return null; - Method create = method("create", new Class[]{String.class, - String.class, - String.class, - String.class, - int.class, - String.class}, - envClass); - if (create == null) return null; - Object env = invoke(create, null, new Object[]{sourcepath, - classpath, - bootclasspath, - extdirs, - new Integer((int)flags), - encoding}); - if (env == null) return null; - - - return null; - } - -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/rootmakers/Javadoc14.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/rootmakers/Javadoc14.java deleted file mode 100644 index 3846c8aba..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/ajdoc/rootmakers/Javadoc14.java +++ /dev/null @@ -1,273 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.ajdoc.rootmakers; - -//import com.sun.javadoc.RootDoc; -//import com.sun.javadoc.DocErrorReporter; -// -//import java.lang.reflect.InvocationTargetException; -//import java.lang.reflect.Constructor; -//import java.lang.reflect.Method; -//import java.util.Iterator; -//import java.util.List; -// -//import org.aspectj.tools.ajdoc.CannotMakeRootDocException; -//import org.aspectj.tools.ajdoc.ErrPrinter; -//import org.aspectj.tools.ajdoc.RootDocMaker; -//import org.aspectj.tools.ajdoc.AccessChecker; - -//XXX -//import com.sun.tools.javac.v8.util.Hashtable; - -/** - * Makes a RootDoc using javadoc from SDK 1.4 as an example. - * - * @author Jeff Palm - */ -//public class Javadoc14 extends Javadoc implements RootDocMaker { -// -// public Javadoc14() {} -// -// public RootDoc makeRootDoc(String sourcepath, -// String classpath, -// String bootclasspath, -// String extdirs, -// long flags, -// String encoding, -// String locale, -// String source, -// List classesAndPackages, -// List options, -// DocErrorReporter docErrorReporter, -// String programName, -// AccessChecker filter) -// throws CannotMakeRootDocException { -// this.err = (ErrPrinter)docErrorReporter; -// Class hashtableClass = null; -// String classname = "com.sun.tools.javac.v8.util.Hashtable"; -// try { -// hashtableClass = Class.forName(classname); -// } catch (ClassNotFoundException e) { -// err.ex(e, "class_not_found", "Hashtable", classname); -// return null; -// } -// Object hashtable = null; -// try { -// hashtable = hashtableClass.newInstance(); -// Method put = hashtableClass.getMethod("put", -// new Class[]{Object.class, -// Object.class}); -// if (sourcepath != null) { -// put.invoke(hashtable, new Object[]{"-sourcepath", -// sourcepath}); -// } -// if (classpath != null) { -// put.invoke(hashtable, new Object[]{"-classpath", -// classpath}); -// } -// if (bootclasspath != null) { -// put.invoke(hashtable, new Object[]{"-bootclasspath", -// bootclasspath}); -// } -// if (extdirs != null) { -// put.invoke(hashtable, new Object[]{"-extdirs", -// extdirs}); -// } -// if (encoding != null) { -// put.invoke(hashtable, new Object[]{"-encoding", -// encoding}); -// } -// if (true || (flags & 0x1) != 0) { -// put.invoke(hashtable, new Object[]{"-verbose", -// ""}); -// } -// if (source != null) { -// put.invoke(hashtable, new Object[]{"-source", -// source}); -// } -// if (filter != null) { -// put.invoke(hashtable, new Object[]{"-" + filter.getOption(), -// ""}); -// } -// Hashtable h = (Hashtable)hashtable; -// -// } catch (NoSuchMethodException e) { -// err.ex(e, "method_not_found", classname, "put"); -// return null; -// } catch (InvocationTargetException e) { -// err.invocationTargetException(e, classname, "put"); -// return null; -// } catch (InstantiationException e) { -// err.ex(e, "must_have_default_ctor", classname); -// return null; -// } catch (IllegalAccessException e) { -// err.ex(e, "method_not_accessible", classname, "new()"); -// return null; -// } -// Class messagerClass = null; -// classname = "com.sun.tools.javadoc.Messager"; -// try { -// messagerClass = Class.forName(classname); -// } catch (ClassNotFoundException e) { -// err.ex(e, "class_not_found", "Messager", classname); -// return null; -// } -// Object messager = null; -// try { -// Constructor ctor = -// messagerClass.getConstructor(new Class[]{String.class}); -// messager = ctor.newInstance(new Object[]{programName}); -// } catch (InstantiationException e) { -// err.ex(e, "cant_construct_object", classname); -// return null; -// } catch (NoSuchMethodException e) { -// err.ex(e, "method_not_found", classname, "new(String)"); -// return null; -// } catch (IllegalAccessException e) { -// err.ex(e, "method_not_accessible", classname, "new(String)"); -// return null; -// } catch (InvocationTargetException e) { -// err.invocationTargetException(e, classname, "new(String)"); -// return null; -// } -// Class javadocToolClass = null; -// classname = "com.sun.tools.javadoc.JavadocTool"; -// try { -// javadocToolClass = Class.forName(classname); -// } catch (ClassNotFoundException e) { -// err.ex(e, "class_not_found", "JavadocTool", classname); -// return null; -// } -// Object javadocTool = null; -// try { -// Method make = javadocToolClass.getMethod("make", -// new Class[]{messagerClass, -// hashtableClass}); -// javadocTool = make.invoke(null, new Object[]{messager, -// hashtable}); -// } catch (NoSuchMethodException e) { -// err.ex(e, "method_not_found", classname, "make"); -// return null; -// } catch (InvocationTargetException e) { -// err.invocationTargetException(e, classname, "make"); -// return null; -// } catch (IllegalAccessException e) { -// err.ex(e, "method_not_accessible", classname, "make"); -// return null; -// } catch (Exception e) { -// err.ex(e, "exception_thrown", "JavadocTool", -// classname, "make", e != null ? e.getMessage() : e+""); -// return null; -// } -// Class modifierFilterClass = null; -// classname = "com.sun.tools.javadoc.ModifierFilter"; -// try { -// modifierFilterClass = Class.forName(classname); -// } catch (ClassNotFoundException e) { -// err.ex(e, "class_not_found", "ModifierFilter", classname); -// return null; -// } -// Object modifierFilter = null; -// classname = "com.sun.tools.javadoc.ModifierFilter"; -// try { -// Constructor ctor = -// modifierFilterClass.getConstructor(new Class[]{long.class}); -// modifierFilter = ctor.newInstance(new Object[]{new Long(flags)}); -// } catch (InstantiationException e) { -// err.ex(e, "cant_construct_object", classname); -// return null; -// } catch (NoSuchMethodException e) { -// err.ex(e, "method_not_found", classname, "new()"); -// return null; -// } catch (IllegalAccessException e) { -// err.ex(e, "method_not_accessible", classname, "new()"); -// return null; -// } catch (InvocationTargetException e) { -// err.invocationTargetException(e, classname, "new()"); -// return null; -// } -// Class listClass = null; -// classname = "com.sun.tools.javac.v8.util.List"; -// try { -// listClass = Class.forName(classname); -// } catch (ClassNotFoundException e) { -// err.ex(e, "class_not_found", "List", classname); -// return null; -// } -// RootDoc rootDoc = null; -// classname = "com.sun.tools.javadoc.JavadocTool"; -// try { -// Method getRootDocImpl = -// javadocToolClass.getMethod("getRootDocImpl", -// new Class[]{String.class, -// modifierFilterClass, -// listClass, -// listClass}); -// Object classesOrPackageList = list(classesAndPackages, listClass); -// Object optionsList = list(options, listClass); -// -// rootDoc = -// (RootDoc)getRootDocImpl.invoke(javadocTool, -// new Object[]{locale, -// modifierFilter, -// classesOrPackageList, -// optionsList}); -// } catch (NoSuchMethodException e) { -// err.ex(e, "method_not_found", classname, "getRootDocImpl"); -// return null; -// } catch (InvocationTargetException e) { -// err.invocationTargetException(e, classname, "getRootDocImpl"); -// return null; -// } catch (IllegalAccessException e) { -// err.ex(e, "method_not_accessible", classname, "getRootDocImpl"); -// return null; -// } catch (ClassCastException e) { -// err.ex(e, "class_cast_exception", "getRootDocImpl", classname, -// "com.sun.javadoc.RootDoc", -// rootDoc == null ? "" : rootDoc.getClass().getName()); -// return null; -// } -// return rootDoc; -// } -// -// -// private final Object list(List list, Class listClass) { -// if (listClass == null) return null; -// Object newlist = newInstance(listClass); -// if (newlist == null) return null; -// if (list == null) return newlist; -// Class listBufferClass = type("com.sun.tools.javac.v8.util.ListBuffer"); -// if (listBufferClass == null) return newlist; -// Object listBuffer = newInstance(listBufferClass); -// if (listBuffer == null) return newlist; -// Method append = method("append", new Class[]{Object.class},listBufferClass); -// if (append == null) return newlist; -// for (Iterator i = list.iterator(); i.hasNext();) { -// invoke(append, listBuffer, new Object[]{i.next()}); -// } -// -// Method toList = method("toList", new Class[]{}, listBufferClass); -// if (toList == null) return newlist; -// newlist = invoke(toList, listBuffer, new Object[]{}); -// return newlist; -// } -//} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/AbstractIndexWriter.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/AbstractIndexWriter.java deleted file mode 100644 index 4adc29409..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/AbstractIndexWriter.java +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.doclets.standard; - -import org.aspectj.ajdoc.AspectDoc; -import org.aspectj.ajdoc.IntroducedDoc; - -import com.sun.javadoc.ClassDoc; -import com.sun.javadoc.MemberDoc; -import com.sun.tools.doclets.IndexBuilder; - -import java.io.IOException; - -public class AbstractIndexWriter - extends com.sun.tools.doclets.standard.AbstractIndexWriter -{ - - protected AbstractIndexWriter(String path, - String filename, - String relativePath, - IndexBuilder indexbuilder) - throws IOException { - super(path, filename, relativePath, indexbuilder); - } - - protected AbstractIndexWriter(String filename, - IndexBuilder indexbuilder) - throws IOException { - super(filename, indexbuilder); - } - - protected void printClassInfo(ClassDoc cd) { - if (cd instanceof AspectDoc) { - print("aspect "); - printPreQualifiedClassLink(cd); - print('.'); - } else { - super.printClassInfo(cd); - } - } - - protected void printMemberDesc(MemberDoc member) { - String classdesc = Statics.type(member.containingClass()) + " " + - getPreQualifiedClassLink(member.containingClass()); - if (member instanceof org.aspectj.ajdoc.MemberDoc) { - org.aspectj.ajdoc.MemberDoc md = (org.aspectj.ajdoc.MemberDoc)member; - if (md.isAdvice()) { - printText("doclet.Advice_in", classdesc); - } else if (md.isPointcut()) { - printText("doclet.Pointcut_in", classdesc); - } - } else { - super.printMemberDesc(member); - } - if (member instanceof org.aspectj.ajdoc.MemberDoc) { - IntroducedDoc intro = - ((org.aspectj.ajdoc.MemberDoc)member).introduced(); - if (intro != null) { - print(' '); - printText("doclet.introduced_by", - Statics.type(intro.containingClass()) + " " + - getPreQualifiedClassLink(intro.containingClass())); - } - } - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/AbstractStandard.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/AbstractStandard.java deleted file mode 100644 index e490eabd6..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/AbstractStandard.java +++ /dev/null @@ -1,477 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.doclets.standard; - -import org.aspectj.ajdoc.AspectDoc; - -import com.sun.javadoc.ClassDoc; -import com.sun.javadoc.DocErrorReporter; -import com.sun.javadoc.PackageDoc; -import com.sun.javadoc.RootDoc; -import com.sun.tools.doclets.ClassTree; -import com.sun.tools.doclets.DocletAbortException; -import com.sun.tools.doclets.HtmlDocWriter; -import com.sun.tools.doclets.IndexBuilder; - -import java.io.IOException; -import java.lang.reflect.Constructor; -import java.util.Arrays; - -/** - * An abstract allowing one to customize the writers - * used in ajdoc. Subclasses should define the three - * generate methods to specify the documentation made. - * - * @see #preGenerationClasses() - * @see #postGenerationClasses() - * @see #checkClasses() - * @author Jeff Palm - */ -public abstract class AbstractStandard - extends com.sun.tools.doclets.standard.Standard { - - // todo wes removed restriction, but implemented Standard as singleton via proxy - private static int refCount = 0; - { - if (refCount > 0) { - System.err.println("Warning: " + refCount + " AbstractStandard already "); - } - refCount++; - } - - /** - * The ClassTree that is available to subclasses and it gaurateed - * to be created before pre-generating classes. - */ - protected ClassTree classtree; - - protected static boolean start(AbstractStandard as, - RootDoc root) throws IOException { - try { - as.getConfiguration().setOptions(root); - as.startGeneration(root); - } catch (DocletAbortException exc) { - return false; - } - return true; - } - - /** - * Returns the types of {@link Pass}es that will - * run before generating classes. - * - * @return an array of Class, where each entry - * is a subclass of {@link Pass}, ordered - * to run directly before generating the - * classes. - */ - protected abstract Class[] preGenerationClasses(); - - /** - * Returns the types of {@link Pass}es that will - * run after generating classes. - * - * @return an array of Class, where each entry - * is a subclass of {@link Pass}, ordered - * to run directly after generating the - * classes. - */ - protected abstract Class[] postGenerationClasses(); - - /** - * Returns the types of {@link CheckPass}es that will - * run to check the classes. - * - * @return an array of Class, where each entry - * is a subclass of {@link CheckPass}, ordered - * to run in order to check the classes passed - * into the class generation phase. - */ - protected abstract Class[] checkClasses(); - - /** - * Return the configuration used by a subclass. This - * allows the subclass to specify it's own kind. - * - * @return a customized configuration. - */ - public abstract ConfigurationStandard getConfiguration(); - - protected ConfigurationStandard makeConfiguration() { - return new ConfigurationStandard(); - } - - - /** - * Returns the configuration, and ensures that - * HtmlDocWriter.configuration is of the type used by - * this class. - * - * @return the current instanceof ConfigurationStandard being - * used and creates one if needed. This will not - * be null. - */ - // todo these are the heinous globals that impose one process per classloader - public static com.sun.tools.doclets.standard.ConfigurationStandard - configuration() { - if (HtmlDocWriter.configuration == null || - !(HtmlDocWriter.configuration instanceof ConfigurationStandard)) { - HtmlDocWriter.configuration = new ConfigurationStandard(); - //TODO: change to makeConfiguration() - } - return (ConfigurationStandard)HtmlDocWriter.configuration; - } - - /** - * Creates and returns an IndexBuilder that includes aspects. - * - * @param root RootDoc to pass the new IndexBuilder. - * @param classesOnly true if only classes - * should be included. - * @return an IndexBuilder that includes aspects. - */ - protected IndexBuilder indexBuilder(RootDoc root, boolean classesOnly) { - class MyIndexBuilder extends IndexBuilder { - public MyIndexBuilder(RootDoc r, boolean n) { - super(r, n); - } - public MyIndexBuilder(RootDoc r, boolean n, boolean b) { - super(r, n, b); - } - protected void putMembersInIndexMap(ClassDoc classdoc) { - super.putMembersInIndexMap(classdoc); - if (classdoc instanceof org.aspectj.ajdoc.ClassDoc) { - org.aspectj.ajdoc.ClassDoc cd = - (org.aspectj.ajdoc.ClassDoc)classdoc; - adjustIndexMap(cd.pointcuts()); - if (cd instanceof AspectDoc) { - adjustIndexMap(((AspectDoc)cd).advice()); - } - } - } - } - return new MyIndexBuilder(root, configuration().nodeprecated, classesOnly); - } - - - /** - * Does the work in generating the documentation. - * First, call all the passes return from {@link #generateCheckPasses} - * them perform some copying. Second build the classtree, run the - * pre-classgeneration passes, generate the packages, generate the - * classes, then call all the postGenerationClasses. - * - * @param root the root of the documentation. - */ - protected void startGeneration(RootDoc root) throws DocletAbortException { - - if (!generateCheckPasses(getConfiguration(), root)) return; - - performCopy(getConfiguration().destdirname, - getConfiguration().helpfile); - performCopy(getConfiguration().destdirname, - getConfiguration().stylesheetfile); - - classtree = new ClassTree(root, getConfiguration().nodeprecated); - - generatePrePasses(getConfiguration(), root); - - generatePackageCycle(getConfiguration().packages, - getConfiguration().createtree, - getConfiguration().nodeprecated); - generateClassFiles(root, classtree); - generatePostPasses(getConfiguration(), root); - } - - /** - * A class representing a single pass in the generation cycles. It - * does some of the dirty work for you. - */ - public static abstract class Pass { - - /** The root available to this pass. */ - protected RootDoc root; - - /** The configuration available to this pass. */ - protected ConfigurationStandard cs; - - /** The doclet available to this pass. */ - protected AbstractStandard std; - - public Pass() {} - - /** - * Returns the title of the pass for logging. - * - * @return the unique title of this pass. This can - * be null to disable display. - */ - public abstract String title(); - - /** - * Do the generation work. All instance variables - * are guaranteed to be set. - */ - protected abstract void gen() throws DocletAbortException; - - /** - * Do the actual generation if {@link #cond} returns - * true. Do some other logging, too. - * - * @param std the AbstractStandard to use. - * @param cs the ConfigurationStandard to use. - * @param root the RootDoc to use. - */ - public final void generate(AbstractStandard std, - ConfigurationStandard cs, - RootDoc root) - throws DocletAbortException { - this.std = std; - this.cs = cs; - this.root = root; - if (cond()) { - String title = title(); - long start = System.currentTimeMillis(); - if (cs.log && title != null) { - cs.standardmessage.notice("doclet.pass_msg", title); - } - gen(); - if (cs.log && title != null) { - long stop = System.currentTimeMillis(); - cs.standardmessage.notice("doclet.done_msg", - title, (stop-start)+""); - } - } - } - - /** - * Returns whether the generation should proceed. Override - * this method for conditional passes. - * - * @return true is this pass shoulud proceed. - */ - protected boolean cond() { - return true; - } - } - - /** - * A convenience class for doing checks. - */ - public abstract static class Check extends Pass { - - /** - * Returns the error message if check fails. - * - * @return error message if check fails. - */ - protected abstract String message(); - - /** - * Returns whether check has failed or not. - * - * @return true is check fails. - */ - protected abstract boolean cond(); - - /** - * Prints message, because we've failed and throws - * a DocletAbortException to notify the doclet - * that we've failed. - */ - protected void gen() throws DocletAbortException { - cs.standardmessage.error(message()); - throw new DocletAbortException(); - } - - /** - * Returns null, because we don't want to be displayed. - * - * @return null. - */ - public String title() { return null; } - } - - /** - * Generates the passes to run before generating the classes. - */ - private final void generatePrePasses(ConfigurationStandard cs, - RootDoc root) - throws DocletAbortException { - generatePasses(cs, root, preGenerationClasses()); - } - - /** - * Generates the passes to run after generating the classes. - */ - private final void generatePostPasses(ConfigurationStandard cs, - RootDoc root) - throws DocletAbortException { - generatePasses(cs, root, postGenerationClasses()); - } - - /** - * Generates the passes that run before doing anything. These - * passes check that it's OK to do anything. - */ - private final boolean generateCheckPasses(ConfigurationStandard cs, - RootDoc root) - throws DocletAbortException { - try { - generatePasses(cs, root, checkClasses()); - } catch (DocletAbortException e) { - return false; - } - return true; - } - - /** - * Generates passes from classes. For each - * class found in classes a constructor taking zero - * or one-argument is called. Then the generate method is - * called on that Pass passing it this, the - * configuration, and root. - * - * @param cs configuration to use. - * @param root root we're documenting. - * @param classes list of subtypes of {@link Pass} that - * will be run. - */ - private final void generatePasses(ConfigurationStandard cs, - RootDoc root, - Class[] classes) - throws DocletAbortException { - if (classes == null) return; - nextClass: - for (int i = 0; i < classes.length; i++) { - try { - Constructor[] ctrs = classes[i].getConstructors(); - nextCtr: - for (int j = 0; j < ctrs.length; j++) { - Pass pass = null; - if (ctrs[j].getParameterTypes().length == 0) { - pass = (Pass)ctrs[j].newInstance(new Object[]{}); - } else if (ctrs[j].getParameterTypes().length == 1) { - pass = (Pass)ctrs[j].newInstance(new Object[]{this}); - } - if (pass != null) { - pass.generate(this,cs,root); - continue nextClass; - } - } - throw new Exception("Can't create pass for class " + classes[i]); - } catch (Exception e) { - e.printStackTrace(); - Standard.configuration().standardmessage. - error("doclet.exception", e+""); - throw new DocletAbortException(); - } - } - } - - - /** - * Generates the packages. - */ - protected void generatePackageCycle(PackageDoc[] pkgs, - boolean createtree, - boolean nodeprecated) - throws DocletAbortException { - Arrays.sort(pkgs); - for (int i = 0; i < pkgs.length; i++) { - PackageDoc prev = i == 0 ? null : pkgs[i-1]; - PackageDoc curr = pkgs[i]; - PackageDoc next = i == pkgs.length-1 ? null : pkgs[i+1]; - generatePackages(prev, curr, next, - createtree, nodeprecated); - } - } - - /** - * Generates a package doc for the three PackageDocs passed. - */ - protected void generatePackages(PackageDoc prev, - PackageDoc curr, - PackageDoc next, - boolean createtree, - boolean nodeprecated) - throws DocletAbortException { - PackageWriter.generate(curr, prev, next); - if (createtree) { - PackageTreeWriter.generate(curr, prev, - next, nodeprecated); - } - PackageFrameWriter.generate(curr); - } - - /** - * Generates all the classes. - */ - protected void generateClassCycle(ClassDoc[] cs, - ClassTree classtree, - boolean nopackage) - throws DocletAbortException { - Arrays.sort(cs); - for(int i = 0; i < cs.length; i++) { - if (configuration().nodeprecated && - cs[i].tags("deprecated").length > 0) { - continue; - } - ClassDoc prev = i == 0 ? null : cs[i-1]; - ClassDoc curr = cs[i]; - ClassDoc next = i == cs.length-1 ? null : cs[i+1]; - generateClasses(prev, curr, next, - classtree, nopackage); - } - } - - /** - * Generates class docs for the three ClassDocs passed. - */ - protected void generateClasses(ClassDoc prev, - ClassDoc curr, - ClassDoc next, - ClassTree classtree, - boolean nopackage) - throws DocletAbortException { - ClassWriter.generate(curr, prev, next, - classtree, nopackage); - } - - /** - * Returns the delegation to {@link #configuration()}. - */ - public static int optionLength(String option) { - return configuration().optionLength(option); - } - - /** - * Returns the delegation to {@link #configuration()}. - */ - public static boolean validOptions(String options[][], - DocErrorReporter reporter) - throws IOException { - return configuration().validOptions(options, reporter); - } -} - - diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/AbstractSubWriter.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/AbstractSubWriter.java deleted file mode 100644 index dbb0d96a6..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/AbstractSubWriter.java +++ /dev/null @@ -1,393 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.doclets.standard; - -import org.aspectj.ajdoc.IntroducedDoc; -import org.aspectj.tools.ajdoc.Access; - -import com.sun.javadoc.ClassDoc; -import com.sun.javadoc.ProgramElementDoc; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - - -public class AbstractSubWriter - extends com.sun.tools.doclets.standard.AbstractSubWriter - implements AbstractSubWriterAJ -{ - - public AbstractSubWriter - (com.sun.tools.doclets.standard.SubWriterHolderWriter writer, - ClassDoc classdoc) - { - super(writer, classdoc); - } - - public AbstractSubWriter - (com.sun.tools.doclets.standard.SubWriterHolderWriter writer) - { - super(writer); - } - - public final void printSummaryMember(ClassDoc cd, ProgramElementDoc member) { - writer.printSummaryLinkType(this, member); - printSummaryLink(cd, member); - printSummaryLinkComment(member); - } - - protected final void printCrosscuts(ProgramElementDoc member) { - if (hasCrosscuts(classdoc, member)) { - writer.dl(); - writer.dd(); - printCrosscuts(classdoc, member); - writer.ddEnd(); - writer.dlEnd(); - } - } - - protected /*abstract*/ Class delegateClass() { throw new RuntimeException(""); } - /*final*/ private com.sun.tools.doclets.standard.AbstractSubWriter del; - { setDelegator(); } - protected final void setDelegator() { - com.sun.tools.doclets.standard.AbstractSubWriter mw = null; - try { - List list = new ArrayList(); - if (writer != null) list.add(writer); - if (classdoc != null) list.add(classdoc); - setDelegator(mw = findDelegate - (list.toArray - (new Object[list.size()]))); - } finally { - del = mw; - } - } - public final com.sun.tools.doclets.standard.AbstractSubWriter del() { - return del; - } - private final void setDelegator(Object o) { - if (o == null) return; - try { - Method[] ms = o.getClass().getMethods(); - for (int i = 0; i < ms.length; i++) { - if (ms[i].getName().equals("setDelegator")) { - ms[i].invoke(o, new Object[]{this}); - } - } - } catch (Exception e) { - Standard.configuration().standardmessage. - error("doclet.exception_encountered", e+""); - } - } - private final com.sun.tools.doclets.standard.AbstractSubWriter - findDelegate(Object[] params) { - if (delegateClass() == null) { - return this; - } - try { - Constructor[] cs = delegateClass().getConstructors(); - for (int i = 0; i < cs.length; i++) { - if (cs[i].getParameterTypes().length == params.length) { - return (com.sun.tools.doclets.standard.AbstractSubWriter) - cs[i].newInstance(params); - } - } - } catch (Exception e) { - Standard.configuration().standardmessage. - error("doclet.exception_encountered", e+""); - } - return null; - } - - public int getMemberKind() { - return -1; - } - public void printSummaryLabel(ClassDoc cd) { - if (keyName() != null) { - summaryLabel(keyName()); - } else { - del.printSummaryLabel(cd); - } - } - public void printSummaryAnchor(ClassDoc cd) { - if (keyName() != null) { - summaryAnchor(keyName()); - } else { - del.printSummaryAnchor(cd); - } - } - public void printInheritedSummaryAnchor(ClassDoc cd) { - del.printInheritedSummaryAnchor(cd); - } - protected void printSummaryType(ProgramElementDoc member) { - Access.printSummaryType(this, member); - } - protected void printSummaryLink(ClassDoc cd, - ProgramElementDoc member) { - Access.printSummaryLink(this, cd, member); - } - protected void printInheritedSummaryLink(ClassDoc cd, - ProgramElementDoc member) { - Access.printInheritedSummaryLink(this, cd, member); - } - protected void printHeader(ClassDoc cd) { - if (keyName() != null) { - header(keyName()); - } else { - Access.printHeader(this, cd); - } - } - protected void printBodyHtmlEnd(ClassDoc cd) { - Access.printBodyHtmlEnd(this, cd); - } - protected final void printMember(ProgramElementDoc elem) { - nonfinalPrintMember(elem); - printCrosscuts(elem); - } - protected void nonfinalPrintMember(ProgramElementDoc elem) { - Access.printMember(this, elem); - } - protected void printDeprecatedLink(ProgramElementDoc member) { - Access.printDeprecatedLink(this, member); - } - protected void printNavSummaryLink(ClassDoc cd, boolean link) { - if (keyName() != null) { - navSummaryLink(cd, keyName(), link); - } else { - Access.printNavSummaryLink(this, cd, link); - } - } - protected void printNavDetailLink(boolean link) { - if (keyName() != null) { - navDetailLink(keyName(), link); - } else { - Access.printNavDetailLink(this, link); - } - } - - protected /*abstract*/ String propertyName() { return keyName(); } - protected /*abstract*/ String keyName() { return null; } - protected final String lowercase() { - String str = propertyName(); - return str == null || str.length() == 0 ? "" : - Character.toLowerCase(str.charAt(0)) + - str.substring(1); - } - public void printInheritedSummaryLabel(ClassDoc cd) { - summaryLabel("Inherited_From", cd); - } - public void printIntroducedSummaryLabel(ClassDoc cd) { - summaryLabel("Introduced_From", cd); - } - public void printIntroducedSummaryAnchor(ClassDoc cd) { - summaryAnchor("introduced_from_class", cd); - } - protected final void summaryLabel(String keyName) { - writer.boldText("doclet." + keyName + "_Summary"); - } - protected final void summaryAnchor(String keyName) { - writer.anchor(keyName.toLowerCase() + "_summary"); - } - protected final void summaryLabel(String type, ClassDoc cd) { - writer.bold(); - writer.printText("doclet." + propertyName() + "s_" + type, - Statics.type(cd), - writer.getPreQualifiedClassLink(cd)); - writer.boldEnd(); - } - protected final void summaryAnchor(String type, ClassDoc cd) { - writer.anchor(lowercase() + "s_" + type + "_" + cd.qualifiedName()); - } - protected final String navKey(String keyName) { - return "doclet.nav" + keyName; - } - protected final String navKey() { - return navKey(keyName()); - } - protected final void navLink(ClassDoc cd, String keyName, - boolean link, String kind) { - if (link) { - writer.printHyperLink - ("", - cd == null ? - keyName.toLowerCase() + "_" + kind : - keyName.toLowerCase() + "s_inherited_from_class_" + - cd.qualifiedName(), - writer.getText(navKey(keyName))); - } else { - writer.printText(navKey(keyName)); - } - } - protected final void navSummaryLink(ClassDoc cd, String keyName, boolean link) { - navLink(cd, keyName, link, "summary"); - } - protected final void navDetailLink(String keyName, boolean link) { - navLink(null, keyName, link, "detail"); - } - protected final void header(String keyName) { - writer.anchor(keyName.toLowerCase() + "_detail"); - writer.printTableHeadingBackground - (writer.getText("doclet." + keyName + "_Detail")); - } - - public void printCrosscuts(ClassDoc cd, ProgramElementDoc member) {} - public void printSummaryCrosscuts(ClassDoc cd, ProgramElementDoc member) {} - public boolean hasCrosscuts(ClassDoc cd,ProgramElementDoc member) { - return false; - } - - protected void printHead(String name) { - writer.h3(); - writer.print(name); - writer.h3End(); - } - - protected List nointros(List members) { - List list = new ArrayList(); - for (Iterator i = members.iterator(); i.hasNext();) { - Object o = i.next(); - if (o instanceof org.aspectj.ajdoc.MemberDoc) { - IntroducedDoc intro = - ((org.aspectj.ajdoc.MemberDoc)o).introduced(); - if (intro == null || intro.containingClass().equals(classdoc)) { - list.add(o); - } - } else { - list.add(o); - } - } - return list; - } - - public void printMembersSummary() { - nointros = true; - super.printMembersSummary(); - nointros = false; - } - - protected final void printSummaryLinkComment(ProgramElementDoc member) { - writer.codeEnd(); - writer.println(); - writer.br(); - Access.printCommentDef(this, member); - boolean newline = member.tags("deprecated").length + - member.firstSentenceTags().length > 0; - if (classdoc != null || true) { // ?? always - if (hasCrosscuts(classdoc, member)) { - if (newline) { - writer.br(); - writer.printNbsps(); - } - printSummaryCrosscuts(classdoc, member); - } - } - writer.summaryRowEnd(); - writer.trEnd(); - } - - public void printIntroducedSummaryHeader(ClassDoc cd) { - printIntroducedSummaryAnchor(cd); - writer.tableIndexSummary(); - writer.tableInheritedHeaderStart("#EEEEFF"); - printIntroducedSummaryLabel(cd); - writer.tableInheritedHeaderEnd(); - writer.trBgcolorStyle("white", "TableRowColor"); - writer.summaryRow(0); - writer.code(); - } - - public void printIntroducedSummaryFooter(ClassDoc cd) { - writer.codeEnd(); - writer.summaryRowEnd(); - writer.trEnd(); - writer.tableEnd(); - writer.space(); - } - - public void printIntroducedSummaryMember(ClassDoc cd, - ProgramElementDoc member) { - printIntroducedSummaryLink(cd, member); - } - - public void printIntroducedSummaryLink(ClassDoc cd, - ProgramElementDoc member) {} - public void printIntroducedMembersSummary() { - Map typesToMembers = new HashMap(); - for (Iterator i = members(classdoc).iterator(); i.hasNext();) { - Object o = i.next(); - if (!(o instanceof org.aspectj.ajdoc.MemberDoc)) continue; - org.aspectj.ajdoc.MemberDoc md = (org.aspectj.ajdoc.MemberDoc)o; - if (md.introduced() != null) { - ClassDoc cd = md.introduced().containingClass(); - List members = (List)typesToMembers.get(cd); - if (members == null) members = new ArrayList(); - members.add(md); - typesToMembers.put(cd, members); - } - } - for (Iterator i = typesToMembers.keySet().iterator(); i.hasNext();) { - ClassDoc cd = (ClassDoc)i.next(); - printIntroducedSummaryHeader(cd); - List members = (List)typesToMembers.get(cd); - Collections.sort(members); - for (Iterator j = members.iterator(); j.hasNext();) { - printIntroducedSummaryMember(cd, (ProgramElementDoc)j.next()); - if (j.hasNext()) print(", "); - } - printIntroducedSummaryFooter(cd); - } - } - - - private boolean nointros = false; - public void printMembers() { - nointros = true; - super.printMembers(); - nointros = false; - } - - public void navSummaryLink() { - nointros = true; - super.navSummaryLink(); - nointros = false; - } - - protected void navDetailLink() { - printNavDetailLink(members(classdoc).size() > 0 ? true : false); - } - - public final List members(ClassDoc cd) { - return nointros ? nointros(getMembers(cd)) : getMembers(cd); - } - - protected List getMembers(ClassDoc cd) { - return super.members(cd); - } -} - - diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/AbstractSubWriterAJ.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/AbstractSubWriterAJ.java deleted file mode 100644 index 75d114e43..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/AbstractSubWriterAJ.java +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.doclets.standard; - -import com.sun.javadoc.ClassDoc; -import com.sun.javadoc.ProgramElementDoc; - -public interface AbstractSubWriterAJ { - public void printCrosscuts(ClassDoc cd, ProgramElementDoc member); - public void printSummaryCrosscuts(ClassDoc cd, ProgramElementDoc member); - public boolean hasCrosscuts(ClassDoc cd, ProgramElementDoc member); - public void printIntroducedSummaryAnchor(ClassDoc cd); - public void printIntroducedSummaryLabel(ClassDoc cd); -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/AbstractTreeWriter.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/AbstractTreeWriter.java deleted file mode 100644 index 504eb4460..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/AbstractTreeWriter.java +++ /dev/null @@ -1,104 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ - -package org.aspectj.tools.doclets.standard; - -import org.aspectj.ajdoc.AspectDoc; - -import com.sun.javadoc.ClassDoc; -import com.sun.javadoc.PackageDoc; -import com.sun.tools.doclets.ClassTree; -import com.sun.tools.doclets.DocletAbortException; - -import java.io.IOException; -import java.util.List; - -public class AbstractTreeWriter - extends com.sun.tools.doclets.standard.AbstractTreeWriter -{ - - protected boolean seenAspect = false; - protected boolean aspectMode = false; - - protected AbstractTreeWriter(String filename, ClassTree classtree) - throws IOException, DocletAbortException { - super(filename, classtree); - } - - protected AbstractTreeWriter(String path, String filename, - ClassTree classtree, PackageDoc pkg) - throws IOException, DocletAbortException { - super(path, filename, classtree, pkg); - } - - protected void generateLevelInfo(ClassDoc parent, List list) { - if (list.size() > 0) { - ul(); - for (int i = 0; i < list.size(); i++) { - ClassDoc local = (ClassDoc)list.get(i); - boolean isAspect = local instanceof org.aspectj.ajdoc.AspectDoc; - if (aspectMode) { - if (!local.qualifiedTypeName().equals("java.lang.Object") - && !isAspect) { - continue; - } - } else if (isAspect) { - continue; - } - printPartialInfo(local); - printExtendsImplements(parent, local); - generateLevelInfo(local, classtree.subs(local)); - } - ulEnd(); - } - } - - protected void printExtendsImplements(ClassDoc parent, ClassDoc cd) { - super.printExtendsImplements(parent, cd); - if (cd instanceof AspectDoc) { - printDominationInfo(((AspectDoc)cd).dominatees(), "dominates"); - printDominationInfo(((AspectDoc)cd).dominators(), "dominated by"); - } - } - - protected void printDominationInfo(AspectDoc[] aspects, - String whosOnTop) { - if (aspects != null && aspects.length > 0) { - print(" (" + whosOnTop + " "); - for (int i = 0; i < aspects.length; i++) { - if (i > 0) print(", "); - printPreQualifiedClassLink(aspects[i]); - } - print(")"); - } - } - - - protected void generateTree(List list, String heading) { - super.generateTree(list, heading); - if (heading.equals("doclet.Class_Hierarchy")) { - aspectMode = true; - generateTree(list, "doclet.Aspect_Hierarchy"); - aspectMode = false; - } - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/AdviceSubWriter.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/AdviceSubWriter.java deleted file mode 100644 index 02b56dd8c..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/AdviceSubWriter.java +++ /dev/null @@ -1,273 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.doclets.standard; - -import org.aspectj.ajdoc.AdviceDoc; -import org.aspectj.ajdoc.AspectDoc; -import org.aspectj.tools.ajdoc.Access; - -import com.sun.javadoc.ClassDoc; -import com.sun.javadoc.ExecutableMemberDoc; -import com.sun.javadoc.MemberDoc; -import com.sun.javadoc.ProgramElementDoc; -import com.sun.javadoc.Tag; -import com.sun.javadoc.Type; -import com.sun.tools.doclets.Util; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; -import java.util.TreeMap; - -public class AdviceSubWriter extends ExecutableMemberSubWriter { - - protected Class delegateClass() { - return MethodSubWriter.class; - } - - public AdviceSubWriter - (com.sun.tools.doclets.standard.SubWriterHolderWriter writer, - AspectDoc aspectdoc) - { - super(writer, aspectdoc); - } - - public AdviceSubWriter - (com.sun.tools.doclets.standard.SubWriterHolderWriter writer) - { - super(writer); - } - - protected final String keyName() { return "Advice"; } - - protected String where(ProgramElementDoc member) { - return getWhere(classdoc, member); - } - - public static String getWhere(ClassDoc cd, ProgramElementDoc member) { - return getName(cd, (AdviceDoc)member).replace(' ','_').replace('#','-'); - } - - protected void printSummaryType(ProgramElementDoc member) { - AdviceDoc advice = (AdviceDoc)member; - printModifiers(advice); - } - - protected void printReturnTag(Tag[] returnsTag) { - if (returnsTag.length > 0) { - writer.dt(); - writer.boldText("doclet.Returns"); - writer.dd(); - writer.printInlineComment(returnsTag[0]); - } - } - - protected void printTagsInfoHeader() { - writer.dd(); - writer.dl(); - } - - protected void printTagsInfoFooter() { - writer.dlEnd(); - writer.ddEnd(); - } - - protected void printSignature(ExecutableMemberDoc member) { - AdviceDoc advice = (AdviceDoc)member; - writer.displayLength = 0; - writer.pre(); - printReturnType(advice); - bold(advice.name()); - printParameters(advice); - if (advice.isThrowing()) { - writer.print(" throwing "); - printExtraType(advice.extraType()); - } - if (advice.isReturning()) { - writer.print(" returning "); - printExtraType(advice.extraType()); - } - writer.preEnd(); - } - - protected void printExtraType(Type type) { - print(' '); - print('('); - if (type != null) { - printTypeLink(type); - } - print(')'); - } - - public static String getName(ClassDoc cd, AdviceDoc advice) { - String name = advice.name(); - int num = 1; - for (Iterator i = staticMembers(cd).iterator(); i.hasNext();) { - AdviceDoc ad = (AdviceDoc)i.next(); - if (ad.equals(advice)) { - break; - } - if (ad.name().equals(name)) { - num++; - } - } - return name + " #" + num; - } - - protected String name(ProgramElementDoc member) { - return getName(classdoc, (AdviceDoc)member); - } - - protected void printParameters(ExecutableMemberDoc member) { - //AdviceDoc advice = (AdviceDoc)member; - Access.printParameters - ((com.sun.tools.doclets.standard.ExecutableMemberSubWriter) - ((AbstractSubWriter)del()).del(), - member); - } - - protected void printReturnType(AdviceDoc advice) { - Type type = advice.returnType(); - if (type != null) { - printTypeLink(type); - print(' '); - } - } - - public void nonfinalPrintMember(ProgramElementDoc elem) { - AdviceDoc advice = (AdviceDoc)elem; - writer.anchor(where(advice)); - printHead(advice); - printSignature(advice); - printFullComment(advice); - } - - protected void printSummaryLink(ClassDoc cd, ProgramElementDoc member) { - ExecutableMemberDoc emd = (ExecutableMemberDoc)member; - String name = emd.name(); - writer.bold(); - writer.printClassLink(cd, where(emd), name, false); - writer.boldEnd(); - writer.displayLength = name.length(); - printParameters(emd); - } - - protected void printHead(MemberDoc member) { - printHead(name(member)); - } - - protected static List staticMembers(ClassDoc classdoc) { - if (!(classdoc instanceof AspectDoc)) return Collections.EMPTY_LIST; - AdviceDoc[] advice = ((AspectDoc)classdoc).advice(); - return advice == null ? Collections.EMPTY_LIST : Util.asList(advice); - } - - protected List getMembers(ClassDoc classdoc) { - return staticMembers(classdoc); - } - - public void printCrosscuts(ClassDoc cd, ProgramElementDoc member) { - if (!(cd instanceof AspectDoc)) return; - //AspectDoc ad = (AspectDoc)cd; - AdviceDoc advice = (AdviceDoc)member; - ExecutableMemberDoc[] crosscuts = advice.crosscuts(); - if (null != crosscuts && crosscuts.length > 0) { - writer.dt(); - writer.boldText("doclet.Crosscuts"); - Set set = new HashSet(); - for (int i = 0; i < crosscuts.length; i++) { - set.add(crosscuts[i]); - } - List list = new ArrayList(set); - Collections.sort(list); - for (Iterator i = list.iterator(); i.hasNext();) { - ExecutableMemberDoc emd = (ExecutableMemberDoc)i.next(); - if (null != emd) { - writer.dd(); - writer.code(); - String where = emd instanceof AdviceDoc - ? where(emd) - : super.where(emd); - writer.printClassLink(emd.containingClass(), - where, label(emd)); - print(" in "); - writer.printClassLink(emd.containingClass()); - writer.codeEnd(); - print('.'); - } - } - } - } - - public void printSummaryCrosscuts(ClassDoc cd, - ProgramElementDoc member) { - - class CCs extends TreeMap { - void add(ExecutableMemberDoc cc) { - if (null != cc) { - Object o = get(cc.containingClass()); - if (o == null) { - o = cc; - } else if (o instanceof ExecutableMemberDoc) { - o = new Integer(2); - } else { - o = new Integer(((Integer)o).intValue()+1); - } - put(cc.containingClass(), o); - } - } - } - - ExecutableMemberDoc[] crosscuts = ((AdviceDoc)member).crosscuts(); - if (crosscuts.length > 0) { - writer.boldText("doclet.Advises"); - CCs ccs = new CCs(); - for (int i = 0; i < crosscuts.length; i++) { - ccs.add(crosscuts[i]); - } - for (Iterator i = ccs.keySet().iterator(); i.hasNext();) { - print(' '); - ClassDoc target = (ClassDoc)i.next(); - Object o = ccs.get(target); - String link; - String name = target.name(); - if (o instanceof AdviceDoc) { - link = where((AdviceDoc)o); - } else if (o instanceof ExecutableMemberDoc) { - link = super.where((ExecutableMemberDoc)o); - } else { - link = "method_detail"; - name += "(" + o + ")"; - } - writer.printClassLink(target, link, name); - if (i.hasNext()) print(","); - } - } - } - - public boolean hasCrosscuts(ClassDoc classDoc, ProgramElementDoc member) { - return true; - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/ClassSubWriter.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/ClassSubWriter.java deleted file mode 100644 index 1587efee4..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/ClassSubWriter.java +++ /dev/null @@ -1,109 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.doclets.standard; - -import org.aspectj.ajdoc.AspectDoc; - -import com.sun.javadoc.ClassDoc; -import com.sun.javadoc.ProgramElementDoc; -import com.sun.javadoc.Type; -import com.sun.tools.doclets.VisibleMemberMap; - -public class ClassSubWriter extends AbstractSubWriter { - - public static class Del extends com.sun.tools.doclets.standard.ClassSubWriter { - protected ClassSubWriter mw; - public Del(com.sun.tools.doclets.standard.SubWriterHolderWriter writer, - ClassDoc classdoc) - { - super(writer, classdoc); - } - public Del(com.sun.tools.doclets.standard.SubWriterHolderWriter writer) - { - super(writer); - } - public void printMembersSummary() { - mw.printMembersSummary(); - mw.printIntroducedMembersSummary(); - if (writer instanceof ClassWriter) { - ((ClassWriter)writer).printAspectJSummary(); - } - } - public void printMembers() { - mw.printMembers(); - } - protected void navSummaryLink() { - mw.navSummaryLink(); - if (writer instanceof ClassWriter) { - ((ClassWriter)writer).navstate++; - } - } - protected void navDetailLink() { - mw.navDetailLink(); - } - public void setDelegator(ClassSubWriter mw) { this.mw = mw; } - } - - protected Class delegateClass() { - return Del.class; - } - - public ClassSubWriter - (com.sun.tools.doclets.standard.SubWriterHolderWriter writer, - ClassDoc classdoc) - { - super(writer, classdoc); - } - - public ClassSubWriter - (com.sun.tools.doclets.standard.SubWriterHolderWriter writer) - { - super(writer); - } - - public int getMemberKind() { - //XXX hack!!! - return VisibleMemberMap.INNERCLASSES; - } - - protected void printSummaryType(ProgramElementDoc member) { - ClassDoc cd = (ClassDoc)member; - printModifierAndType(cd, null); - } - - protected void printModifierAndType(ProgramElementDoc member, - Type type) { - writer.printTypeSummaryHeader(); - printModifier(member); - if (type == null) { - print(member instanceof AspectDoc ? - "aspect" : member.isClass() ? - "class" : - "interface"); - } else { - printTypeLink(type); - } - writer.printTypeSummaryFooter(); - } -} - - diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/ClassUseMapper.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/ClassUseMapper.java deleted file mode 100644 index 8c1a1ab89..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/ClassUseMapper.java +++ /dev/null @@ -1,294 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.doclets.standard; - -import org.aspectj.ajdoc.AdviceDoc; -import org.aspectj.ajdoc.AspectDoc; -import org.aspectj.ajdoc.IntroducedDoc; -import org.aspectj.ajdoc.IntroducedSuperDoc; -import org.aspectj.ajdoc.IntroductionDoc; -import org.aspectj.ajdoc.PointcutDoc; -import org.aspectj.tools.ajdoc.Util; - -import com.sun.javadoc.ClassDoc; -import com.sun.javadoc.ExecutableMemberDoc; -import com.sun.javadoc.FieldDoc; -import com.sun.javadoc.MemberDoc; -import com.sun.javadoc.PackageDoc; -import com.sun.javadoc.Parameter; -import com.sun.javadoc.ProgramElementDoc; -import com.sun.javadoc.RootDoc; -import com.sun.javadoc.Type; -import com.sun.tools.doclets.ClassTree; -import com.sun.tools.doclets.DocletAbortException; - -import java.lang.reflect.Constructor; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -/** - * Provides support for aspects. - * - * @author Jeff Palm - */ -public class ClassUseMapper { - - - /** - * Maps a ClassDoc to advice that return its type. - */ - public final Map classToAdviceReturn = new HashMap(); - - /** - * Maps a ClassDoc to advice that have its type - * are arguments. - */ - public final Map classToAdviceArgs = new HashMap(); - - /** - * Maps a ClassDoc to pointcuts that return its type. - */ - public final Map classToPointcutReturn = new HashMap(); - - /** - * Maps a ClassDoc to pointcuts that have its type - * as arguments. - */ - public final Map classToPointcutArgs = new HashMap(); - - /** - * Maps a ClassDoc to field introductions that - * are its type. - */ - public final Map classToFieldIntroductions = new HashMap(); - - /** - * Maps a ClassDoc to class introductions that - * are its type. - */ - public final Map classToClassIntroductions = new HashMap(); - - /** - * Maps a ClassDoc to interface introductions that - * are its type. - */ - public final Map classToInterfaceIntroductions = new HashMap(); - - /** - * Maps a ClassDoc to aspects that advise it. - */ - public final Map classToAdvisors = new HashMap(); - - /** - * Maps a ClassDoc to aspects that it dominates. - */ - public final Map classToDominatees = new HashMap(); - - /** - * Maps a ClassDoc to aspects that dominate it.. - */ - public final Map classToDominators = new HashMap(); - - - public static void generate(RootDoc root, ClassTree classtree) - throws DocletAbortException { - try { - - ClassUseMapper mapper = new ClassUseMapper(root, classtree); - - ClassDoc[] classes = root.classes(); - for (int i = 0; i < classes.length; i++) { - ClassUseWriter.generate(mapper, classes[i]); - } - PackageDoc[] pkgs = Standard.configuration().packages; - for (int i = 0; i < pkgs.length; i++) { - com.sun.tools.doclets.standard.PackageUseWriter. - generate(mapper.mapper, pkgs[i]); - } - } catch (Exception e) { - e.printStackTrace(); - Standard.configuration().standardmessage. - error("doclet.exception", e+"", - "creating class use tree"); - throw new DocletAbortException(); - } - } - - protected final com.sun.tools.doclets.standard.ClassUseMapper mapper; - - public ClassUseMapper(RootDoc root, ClassTree classtree) - throws Exception { - Constructor constr = - com.sun.tools.doclets.standard.ClassUseMapper.class. - getDeclaredConstructor(new Class[] { - com.sun.javadoc.RootDoc.class, - com.sun.tools.doclets.ClassTree.class, - }); - constr.setAccessible(true); - mapper = (com.sun.tools.doclets.standard.ClassUseMapper)constr. - newInstance(new Object[]{root, classtree}); - - classToPackageSave = new HashMap(); - for (Iterator i = mapper.classToPackage.keySet().iterator(); i.hasNext();) { - Object key = i.next(); - classToPackageSave.put(key, new HashSet((Collection) - mapper.classToPackage. - get(key))); - } - - finish(root, classtree); - } - - protected Object saved; - protected final Map classToPackageSave; - protected final com.sun.tools.doclets.standard.ClassUseMapper mapper - (ClassDoc classdoc) - { - Object noaspects = classToPackageSave.get(classdoc); - saved = mapper.classToPackage.get(classdoc); - mapper.classToPackage.put(classdoc, noaspects); - return mapper; - } - - protected void restore(ClassDoc classdoc) { - mapper.classToPackage.put(classdoc, saved); - } - - protected void finish(RootDoc root, ClassTree classtree) { - - ClassDoc[] classes = root.classes(); - for (int i = 0; i < classes.length; i++) { - ClassDoc cd = classes[i]; - if (cd instanceof org.aspectj.ajdoc.ClassDoc) { - org.aspectj.ajdoc.ClassDoc acd = (org.aspectj.ajdoc.ClassDoc)cd; - PointcutDoc[] pcs = acd.pointcuts(); - for (int j = 0; j < pcs.length; j++) { - PointcutDoc pd = pcs[j]; - mapExecutable(pd); - Type result = pd.resultType(); - if (result != null) { - ClassDoc tcd = result.asClassDoc(); - if (tcd != null) { - add(classToPointcutReturn, tcd, pd); - } - } - } - } - - if (cd instanceof AspectDoc) { - AspectDoc ad = (AspectDoc)cd; - AdviceDoc[] adocs = ad.advice(); - for (int j = 0; j < adocs.length; j++) { - AdviceDoc adoc = adocs[j]; - mapExecutable(adoc); - Type result = adoc.returnType(); - if (result != null) { - ClassDoc tcd = result.asClassDoc(); - if (tcd != null) { - add(classToAdviceReturn, tcd, adoc); - } - } - ExecutableMemberDoc[] emds = adoc.crosscuts(); - if (null != emds) { - for (int k = 0; k < emds.length; k++) { - ExecutableMemberDoc emd = emds[k]; - if (null != emd) { - ClassDoc tcd = emd.containingClass(); - ClassDoc fcd = adoc.containingClass(); - //TODO: This probably sucks!!! - if (!refList(classToAdvisors, tcd).contains(fcd)) { - add(classToAdvisors, tcd, fcd); - } - } - } - } - } - - IntroductionDoc[] ids = ad.introductions(); - for (int j = 0; j < ids.length; j++) { - IntroductionDoc id = ids[j]; - if (id instanceof IntroducedDoc) { - IntroducedDoc idd = (IntroducedDoc)id; - MemberDoc mem = idd.member(); - if (mem.isField()) { - FieldDoc fd = (FieldDoc)mem; - ClassDoc tcd = fd.type().asClassDoc(); - add(classToFieldIntroductions, tcd, fd); - } - } else if (id instanceof IntroducedSuperDoc) { - IntroducedSuperDoc idd = (IntroducedSuperDoc)id; - boolean isImplements = idd.isImplements(); - Type[] types = idd.types(); - for (int k = 0; k < types.length; k++) { - ClassDoc tcd = types[k].asClassDoc(); - add(isImplements ? - classToInterfaceIntroductions : - classToClassIntroductions, tcd, idd); - } - } - } - AspectDoc[] dominatees = ad.dominatees(); - for (int j = 0; j < dominatees.length; j++) { - add(classToDominatees, ad, dominatees[j]); - } - AspectDoc[] dominators = ad.dominators(); - for (int j = 0; j < dominators.length; j++) { - add(classToDominators, ad, dominators[j]); - } - } - } - } - - protected void mapExecutable(ExecutableMemberDoc em) { - Parameter[] params = em.parameters(); - List classargs = new ArrayList(); - Map argsmap = ((org.aspectj.ajdoc.MemberDoc)em).isAdvice() ? - classToAdviceArgs : classToPointcutArgs ; - for (int i = 0; i < params.length; i++) { - ClassDoc pcd = params[i].type().asClassDoc(); - if (pcd != null && !classargs.contains(pcd)) { - add(argsmap, pcd, em); - classargs.add(pcd); - } - } - } - - protected List refList(Map map, ClassDoc cd) { - return (List)Util.invoke(mapper, "refList", - new Class[]{java.util.Map.class, - com.sun.javadoc.ClassDoc.class}, - new Object[]{map, cd}); - } - - protected void add(Map map, ClassDoc cd, ProgramElementDoc ref) { - Util.invoke(mapper, "add", - new Class[]{java.util.Map.class, - com.sun.javadoc.ClassDoc.class, - com.sun.javadoc.ProgramElementDoc.class}, - new Object[]{map, cd, ref}); - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/ClassUseWriter.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/ClassUseWriter.java deleted file mode 100644 index 97ab8020c..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/ClassUseWriter.java +++ /dev/null @@ -1,272 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.doclets.standard; - -import org.aspectj.tools.ajdoc.Access; -import org.aspectj.tools.ajdoc.Util; - -import com.sun.javadoc.ClassDoc; -import com.sun.javadoc.PackageDoc; -import com.sun.tools.doclets.DirectoryManager; -import com.sun.tools.doclets.DocletAbortException; - -import java.io.File; -import java.io.IOException; -import java.util.Map; - -/** - * Provides support for aspects. - * - * @author Jeff Palm - */ -public class ClassUseWriter - extends com.sun.tools.doclets.standard.ClassUseWriter -{ - - /** - * The target ClassDoc. - */ - protected final ClassDoc classdoc; - - /** - * Maps PackageDocs to advice arguments. - */ - protected final Map pkgToAdviceArgs; - - /** - * Maps PackageDocs to advice return types. - */ - protected final Map pkgToAdviceReturn; - - /** - * Maps PackageDocs to pointcut arguments. - */ - protected final Map pkgToPointcutArgs; - - /** - * Maps PackageDocs to pointcut return types. - */ - protected final Map pkgToPointcutReturn; - - /** - * Maps PackageDocs to field introductions. - */ - protected final Map pkgToFieldIntroductions; - - /** - * Maps PackageDocs to class introductions. - */ - protected final Map pkgToClassIntroductions; - - /** - * Maps PackageDocs to interface introductions. - */ - protected final Map pkgToInterfaceIntroductions; - - /** - * Maps PackageDocs to class advisors. - */ - protected final Map pkgToClassAdvisors; - - /** - * Maps PackageDocs to aspects that dominate - * aspects in that package. - */ - protected final Map pkgToAspectDominatees; - - /** - * Maps PackageDocs to aspects that are dominated - * by aspects in that package. - */ - protected final Map pkgToAspectDominators; - - /** - * The MethodSubWriter to use. - */ - protected final MethodSubWriter methodSubWriter - = new MethodSubWriter(this); - - /** - * The ConstructorSubWriter to use. - */ - protected final ConstructorSubWriter constrSubWriter - = new ConstructorSubWriter(this); - - /** - * The FieldSubWriter to use. - */ - protected final FieldSubWriter fieldSubWriter - = new FieldSubWriter(this); - - /** - * The ClassSubWriter to use. - */ - protected final ClassSubWriter classSubWriter - = new ClassSubWriter(this); - - /** - * The PointcutSubWriter to use. - */ - protected final PointcutSubWriter pointcutSubWriter - = new PointcutSubWriter(this); - - /** - * The SuperIntroductionSubWriter to use. - */ - protected final SuperIntroductionSubWriter superIntroductionSubWriter - = new SuperIntroductionSubWriter(this); - - /** - * The FieldIntroductionSubWriter to use. - */ - protected final FieldIntroductionSubWriter fieldIntroductionSubWriter - = new FieldIntroductionSubWriter(this); - - /** - * The ConstructorIntroductionSubWriter to use. - */ - protected final ConstructorIntroductionSubWriter constrIntroductionSubWriter - = new ConstructorIntroductionSubWriter(this); - - /** - * The MethodIntroductionSubWriter to use. - */ - protected final MethodIntroductionSubWriter methodIntroductionSubWriter - = new MethodIntroductionSubWriter(this); - - /** - * The AdviceSubWriter to use. - */ - protected final AdviceSubWriter adviceSubWriter - = new AdviceSubWriter(this); - - - - public ClassUseWriter(ClassUseMapper mapper, - String path, - String filename, - String relpath, - ClassDoc classdoc) - throws IOException, DocletAbortException { - - super(mapper.mapper(classdoc), path, - filename, relpath, classdoc); - - mapper.restore(classdoc); - - this.classdoc = Access.classdoc(this); - - this.pkgToAdviceReturn = - _pkgDivide(mapper.classToAdviceReturn); - this.pkgToAdviceArgs = - _pkgDivide(mapper.classToAdviceArgs); - this.pkgToPointcutReturn = - _pkgDivide(mapper.classToPointcutReturn); - this.pkgToPointcutArgs = - _pkgDivide(mapper.classToPointcutArgs); - this.pkgToFieldIntroductions = - _pkgDivide(mapper.classToFieldIntroductions); - this.pkgToClassIntroductions = - _pkgDivide(mapper.classToClassIntroductions); - this.pkgToInterfaceIntroductions = - _pkgDivide(mapper.classToInterfaceIntroductions); - this.pkgToClassAdvisors = - _pkgDivide(mapper.classToAdvisors); - this.pkgToAspectDominatees = - _pkgDivide(mapper.classToDominatees); - this.pkgToAspectDominators = - _pkgDivide(mapper.classToDominators); - } - - protected com.sun.tools.doclets.standard.ClassUseWriter - writer; - private Map _pkgDivide(Map classMap) { - return (Map)Util.invoke - (com.sun.tools.doclets.standard.ClassUseWriter.class, - this, "pkgDivide", - new Class[]{java.util.Map.class}, - new Object[]{classMap}); - } - - public static void generate(ClassUseMapper mapper, - ClassDoc classdoc) - throws DocletAbortException { - ClassUseWriter cw = null; - String path = DirectoryManager.getDirectoryPath(classdoc. - containingPackage()); - if (path.length() > 0) { - path += File.separator; - } - path += "class-use"; - String filename = classdoc.name() + ".html"; - String pkgname = classdoc.containingPackage().name(); - pkgname += (pkgname.length() > 0 ? "." : "") + "class-use"; - String relpath = DirectoryManager.getRelativePath(pkgname); - try { - (cw = new ClassUseWriter(mapper, path, filename, - relpath, classdoc)). - generateClassUseFile(); - } catch (IOException e) { - Standard.configuration().standardmessage. - error("doclet.exception_encountered", e+"", filename); - throw new DocletAbortException(); - } finally { - if (cw != null) cw.close(); - } - } - - protected void generateClassUse(PackageDoc pkg) throws IOException { - super.generateClassUse(pkg); - String classlink = getClassLink(classdoc); - String pkglink = getPackageLink(pkg); - - printUseInfo(adviceSubWriter, pkgToAdviceReturn, - pkg, "AdviceReturn", classlink, pkglink); - printUseInfo(adviceSubWriter, pkgToAdviceArgs, - pkg, "AdviceArgs", classlink, pkglink); - printUseInfo(pointcutSubWriter, pkgToPointcutReturn, - pkg, "PointcutReturn", classlink, pkglink); - printUseInfo(pointcutSubWriter, pkgToPointcutArgs, - pkg, "PointcutArgs", classlink, pkglink); - printUseInfo(fieldIntroductionSubWriter, pkgToFieldIntroductions, - pkg, "FieldIntroductions", classlink, pkglink); - printUseInfo(superIntroductionSubWriter, pkgToClassIntroductions, - pkg, "ClassIntroductions", classlink, pkglink); - printUseInfo(superIntroductionSubWriter, pkgToInterfaceIntroductions, - pkg, "InterfaceIntroductions", classlink, pkglink); - printUseInfo(classSubWriter, pkgToClassAdvisors, - pkg, "ClassAdvisors", classlink, pkglink); - - printUseInfo(classSubWriter, pkgToAspectDominatees, - pkg, "AspectDominatees", classlink, pkglink); - printUseInfo(classSubWriter, pkgToAspectDominators, - pkg, "AspectDominators", classlink, pkglink); - } - - protected final void printUseInfo(AbstractSubWriter mw, Map map, - PackageDoc pkg, String kind, - String classlink, String pkglink) { - Access.printUseInfo(mw, map.get(pkg), - getText("doclet.ClassUse_" + kind, - classlink,pkglink)); - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/ClassWriter.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/ClassWriter.java deleted file mode 100644 index 7ae643524..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/ClassWriter.java +++ /dev/null @@ -1,554 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.doclets.standard; - -import org.aspectj.ajdoc.AdviceDoc; -import org.aspectj.ajdoc.AspectDoc; -import org.aspectj.ajdoc.IntroducedDoc; -import org.aspectj.ajdoc.IntroducedSuperDoc; -import org.aspectj.ajdoc.IntroductionDoc; -import org.aspectj.ajdoc.OfClauseDoc; -import org.aspectj.ajdoc.OfEachObjectDoc; - -import com.sun.javadoc.ClassDoc; -import com.sun.javadoc.ExecutableMemberDoc; -import com.sun.javadoc.MemberDoc; -import com.sun.tools.doclets.ClassTree; -import com.sun.tools.doclets.DirectoryManager; -import com.sun.tools.doclets.DocletAbortException; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.Set; -import java.util.TreeSet; - -public class ClassWriter extends com.sun.tools.doclets.standard.ClassWriter { - - /** - * The MethodSubWriter that prints out the methods - * of classdoc. - */ - protected MethodSubWriter ourMethodSubWriter; - - /** - * The ConstructorSubWriter that prints out the constructors - * of classdoc. - */ - protected ConstructorSubWriter ourConstrSubWriter; - - /** - * The FieldSubWriter that prints out the fields - * of classdoc. - */ - protected FieldSubWriter ourFieldSubWriter; - - /** - * The ClassSubWriter that prints out the classs - * of classdoc. - */ - protected ClassSubWriter ourInnerSubWriter; - - /** - * The PointcutSubWriter that prints out the pointcuts - * of classdoc. - */ - protected PointcutSubWriter pointcutSubWriter = null; - - /** - * The SuperIntroductionSubWriter that prints out the superintroductions - * of classdoc. - */ - protected SuperIntroductionSubWriter superIntroductionSubWriter = null; - - /** - * The FieldIntroductionSubWriter that prints out the fieldintroductions - * of classdoc. - */ - protected FieldIntroductionSubWriter fieldIntroductionSubWriter = null; - - /** - * The ConstructorIntroductionSubWriter that prints out the constructorintroductions - * of classdoc. - */ - protected ConstructorIntroductionSubWriter constrIntroductionSubWriter = null; - - /** - * The MethodIntroductionSubWriter that prints out the methodintroductions - * of classdoc. - */ - protected MethodIntroductionSubWriter methodIntroductionSubWriter = null; - - /** - * The AdviceSubWriter that prints out the advices - * of classdoc. - */ - protected AdviceSubWriter adviceSubWriter = null; - - - /** - * Construct a ClassWriter from the passed in arguments. This - * will instantiate the subwriters to be used. - * - * @param path the path directory of the html file to generate. - * @param filename the html file to generate. - * @param classdoc the ClassDoc for which this file will - * be generated. - * @param prev the ClassDoc preceding classdoc - * in order of generation. - * @param next the ClassDoc following classdoc - * in order of generation. - * @param classtree the ClassTree to use. - * @param nopackage whether this classdoc's package - * is specified to be documented. - */ - public ClassWriter(String path, - String filename, - ClassDoc classdoc, - ClassDoc prev, - ClassDoc next, - ClassTree classtree, - boolean nopackage) - throws IOException, DocletAbortException { - - super(path, filename, classdoc, prev, - next, classtree, nopackage); - - // Construct the subwriters just for ClassDocs - // We want our superclass to delegate to our subwriters delegate, - // but we want to call our subwriters. So we set our superclasses - // subwriters to our subwriters delegates. - ourMethodSubWriter = new MethodSubWriter(this, classdoc); - methodSubWriter = (com.sun.tools.doclets.standard.MethodSubWriter) - ourMethodSubWriter.del(); - constrSubWriter = (com.sun.tools.doclets.standard.ConstructorSubWriter) - (ourConstrSubWriter = new ConstructorSubWriter(this, classdoc)).del(); - fieldSubWriter = (com.sun.tools.doclets.standard.FieldSubWriter) - (ourFieldSubWriter = new FieldSubWriter(this, classdoc)).del(); - innerSubWriter = (com.sun.tools.doclets.standard.ClassSubWriter) - (ourInnerSubWriter = new ClassSubWriter(this, classdoc)).del(); - - if (classdoc instanceof org.aspectj.ajdoc.ClassDoc) { - pointcutSubWriter = - new PointcutSubWriter(this, (org.aspectj.ajdoc.ClassDoc)classdoc); - } - - // If we've been passed an AspectDoc, create the AspectJ-specfic - // subwriters - if (classdoc instanceof AspectDoc) { - AspectDoc ad = (AspectDoc)classdoc; - superIntroductionSubWriter = new SuperIntroductionSubWriter(this, ad); - fieldIntroductionSubWriter = new FieldIntroductionSubWriter(this, ad); - constrIntroductionSubWriter = new ConstructorIntroductionSubWriter(this, ad); - methodIntroductionSubWriter = new MethodIntroductionSubWriter(this, ad); - adviceSubWriter = new AdviceSubWriter(this, ad); - } - } - - public static void generate(ClassDoc classdoc, - ClassDoc prev, - ClassDoc next, - ClassTree classtree, - boolean nopackage) - throws DocletAbortException { - ClassWriter cw = null; - String path = DirectoryManager.getDirectoryPath - (classdoc.containingPackage()); - String filename = classdoc.name() + ".html"; - try { - (cw = new ClassWriter(path, filename, classdoc, - prev, next, classtree, nopackage)). - generateClassFile(); - } catch (IOException e) { - Standard.configuration().standardmessage. - error("doclet.exception_encountered", e+"", filename); - throw new DocletAbortException(); - } finally { - if (cw != null) cw.close(); - } - } - - /** - * Prints the header of the class -- which is one - * of class, interface or - * aspect with the name title. - * - * @param title the name of the class. - */ - public void printHeader(String title) { - int ispace = title.indexOf(' '); - if (ispace != -1) { - title = Statics.type(classdoc) + title.substring(ispace); - } - super.printHeader(title); - } - - /* - * This is set up to intercept calls to print out - * the correct type of classdoc before we automatically - * print 'class' or 'interface'. - */ - - private boolean h2warn = false; - - /** - * If we've started to print a h2 heading, we're - * printing the name of the class so get ready to - * to intercept the call. - */ - public void h2() { - h2warn = true; - super.h2(); - } - - /** - * After printing the class declaration with the h2 heading - * turn off the h2 warning. - */ - public void h2End() { - h2warn = false; - super.h2End(); - } - - /** - * This is where we intercept the call to print so - * we can print the correct type. - */ - public void print(String str) { - if (h2warn) { - int ispace = str.indexOf(' '); - if (ispace != -1 && str.charAt(0) == 'C') { - str = Statics.type(classdoc) + str.substring(ispace); - } - } - super.print(str); - } - - /** - * Print the members summary for our AspectJ subwriters. - */ - protected void printAspectJSummary() { - printMembersSummary(superIntroductionSubWriter); - printMembersSummary(fieldIntroductionSubWriter); - printMembersSummary(constrIntroductionSubWriter); - printMembersSummary(methodIntroductionSubWriter); - printMembersSummary(pointcutSubWriter); - printMembersSummary(adviceSubWriter); - } - - /** - * Formats the output correctly for a member summary. - * - * @param mw the AbstractSubWriter to use. - */ - protected final void printMembersSummary(AbstractSubWriter mw) { - if (mw != null) { - println(); - println(""); - println(); - mw.printMembersSummary(); - } - } - - /** - * Print the members detail for our AspectJ subwriters. - */ - protected void printAspectJDetail() { - printMembersDetail(superIntroductionSubWriter); - printMembersDetail(fieldIntroductionSubWriter); - printMembersDetail(constrIntroductionSubWriter); - printMembersDetail(methodIntroductionSubWriter); - printMembersDetail(pointcutSubWriter); - printMembersDetail(adviceSubWriter); - } - - /** - * Formats the output correctly for a member detail. - * - * @param mw the AbstractSubWriter to use. - */ - protected final void printMembersDetail(AbstractSubWriter mw) { - if (mw != null) { - println(""); - println(); - mw.printMembers(); - println(); - } - } - - //TODO: Just need to make sure 'aspect; shows up and - //TODO not 'class' - protected void printClassDescription() { - boolean isInterface = classdoc.isInterface(); - boolean isAspect = classdoc instanceof AspectDoc; - dl(); - dt(); - - print(classdoc.modifiers() + " "); - - if (!isInterface) { - print(isAspect ? "aspect " : "class "); - } - bold(classdoc.name()); - - if (!isInterface) { - ClassDoc superclass = classdoc.superclass(); - if (superclass != null) { - dt(); - print("extends "); - printClassLink(superclass); - printIntroducedSuper(superclass); - } - } - - ClassDoc[] implIntfacs = classdoc.interfaces(); - if (implIntfacs != null && implIntfacs.length > 0) { - dt(); - print(isInterface? "extends " : "implements "); - for (int i = 0; i < implIntfacs.length; i++) { - if (i > 0) print(", "); - printClassLink(implIntfacs[i]); - printIntroducedSuper(implIntfacs[i]); - } - } - if (isAspect) { - AspectDoc ad = (AspectDoc)classdoc; - OfClauseDoc ofClause = ad.ofClause(); - if (ofClause != null) { - dt(); - if (ofClause.kind() == OfClauseDoc.Kind.EACH_CFLOW) { - print("percflow(..)"); - } else if (ofClause.kind() == OfClauseDoc.Kind.EACH_JVM) { - print("issingleton()"); - } else if (ofClause.kind() == OfClauseDoc.Kind.EACH_OBJECT) { - print("pertarget("); - printClassLinks(((OfEachObjectDoc)ofClause).instances()); - print(")"); - } - } - AspectDoc[] dominatees = ad.dominatees(); - if (dominatees != null && dominatees.length > 0) { - dt(); - print("dominates "); - printClassLinks(dominatees); - } - AspectDoc[] dominators = ad.dominators(); - if (dominators != null && dominators.length > 0) { - dt(); - print("dominated by "); - printClassLinks(dominators); - } - } - dlEnd(); - } - - /** - * Prints a list of class links separated by commas. - * - * @param cds array of ClassDoc to be printed. - */ - protected void printClassLinks(ClassDoc[] cds) { - if (cds == null || cds.length < 1) return; - for (int i = 0; i < cds.length; i++) { - if (i > 0) print(", "); - if (cds[i] != null) { - printClassLink(cds[i]); - } - } - } - - /** - * Prints information about classdoc's type introduction - * if cd's type was introduced onto classdoc. - * - * @param cd the ClassDoc being printed. - */ - protected void printIntroducedSuper(ClassDoc cd) { - IntroducedSuperDoc[] intros = - ((org.aspectj.ajdoc.ClassDoc)classdoc).introducers(); - if (null != intros) { - for (int i = 0; i < intros.length; i++) { - IntroducedSuperDoc intro = intros[i]; - org.aspectj.ajdoc.Type[] types = intro.types(); - for (int j = 0; j < types.length; j++) { - if (types[j].equals(cd)) { - print(' '); - printText("doclet.by_parens", - getClassLink - (intro.containingClass(), - superIntroductionSubWriter.link(intro), - "introduced"), - getClassLink(intro.containingClass())); - break; - } - } - } - } - } - - /** - * Print the navSummaryLink for all the AspectJ subwriters. - */ - protected void navAspectJSummaryLinks() { - navSummaryLink(superIntroductionSubWriter); - navSummaryLink(fieldIntroductionSubWriter); - navSummaryLink(constrIntroductionSubWriter); - navSummaryLink(methodIntroductionSubWriter); - navSummaryLink(pointcutSubWriter); - navSummaryLink(adviceSubWriter); - } - - /** - * Prints the navSummaryLink correctly. - * - * @param mw AbstractSubWriter to invoke. - */ - protected final void navSummaryLink(AbstractSubWriter mw) { - if (mw != null) { - mw.navSummaryLink(); - _navGap(); - } - } - - /** - * Print the navDetailLink for all the AspectJ subwriters. - */ - protected void navAspectJDetailLinks() { - navDetailLink(superIntroductionSubWriter); - navDetailLink(fieldIntroductionSubWriter); - navDetailLink(constrIntroductionSubWriter); - navDetailLink(methodIntroductionSubWriter); - navDetailLink(pointcutSubWriter); - navDetailLink(adviceSubWriter); - } - - /** - * Prints the navDetailLink correctly. - * - * @param mw AbstractSubWriter to invoke. - */ - protected final void navDetailLink(AbstractSubWriter mw) { - if (mw != null) { - mw.navDetailLink(); - _navGap(); - } - } - - /* - * A hack... I'll explain later, if you need to change - * this mail jeffrey_palm@hotmail.com. - */ - - protected final void _navGap() { super.navGap(); } - - protected int navstate = 0; - protected void navGap() { - _navGap(); - if (navstate == 1) { - navAspectJSummaryLinks(); - navstate++; - } else if (navstate == 3) { - navAspectJDetailLinks(); - navstate++; - } - } - - protected void printEnclosingClassInfo() { - super.printEnclosingClassInfo(); - printAdvisorInfo(); - printAdviseeInfo(); - } - - protected void printAdviseeInfo() { - if (!(classdoc instanceof AspectDoc)) return; - AspectDoc ad = (AspectDoc)classdoc; - Set set = new TreeSet(); - AdviceDoc[] as = ad.advice(); - if (as != null) { - for (int i = 0; i < as.length; i++) { - ExecutableMemberDoc[] crosscuts = as[i].crosscuts(); - if (null != crosscuts) { - for (int j = 0; j < crosscuts.length; j++) { - if (null != crosscuts[j]) { - set.add(crosscuts[j].containingClass()); - } - } - } - } - } - IntroductionDoc[] is = ad.introductions(); - if (null != is) { - for (int i = 0 ; i < is.length; i++) { - ClassDoc[] targets = is[i].targets(); - for (int j = 0; j < targets.length; j++) { - set.add(targets[j]); - } - } - printInfo(set, "doclet.All_Advisees"); - } - } - - protected void printAdvisorInfo() { - Set set = new TreeSet(); - set.addAll(advisors(classdoc.fields())); - set.addAll(advisors(classdoc.methods())); - set.addAll(advisors(classdoc.constructors())); - printInfo(set, "doclet.All_Advisors"); - } - - protected void printInfo(Collection classdocs, String str) { - if ((null != classdocs) && (classdocs.size() > 0)) { - printInfoHeader(); - boldText(str); - dd(); - for (Iterator i = classdocs.iterator(); i.hasNext();) { - printClassLink((ClassDoc)i.next()); - if (i.hasNext()) print(", "); - } - ddEnd(); - dlEnd(); - } - } - - protected final Collection advisors(final MemberDoc[] ms) { - List list = new ArrayList(); - if (null != ms) { - for (int i = 0 ; i < ms.length; i++) { - IntroducedDoc id = - ((org.aspectj.ajdoc.MemberDoc)ms[i]).introduced(); - if (id != null) list.add(id.containingClass()); - if (ms[i] instanceof org.aspectj.ajdoc.ExecutableMemberDoc) { - AdviceDoc[] as = - ((org.aspectj.ajdoc.ExecutableMemberDoc)ms[i]).advice(); - for (int j = 0; j < as.length; j++) { - list.add(as[j].containingClass()); - } - } - } - } - return list; - } -} - - diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/ConfigurationStandard.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/ConfigurationStandard.java deleted file mode 100644 index 8de96b8dc..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/ConfigurationStandard.java +++ /dev/null @@ -1,120 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ - -package org.aspectj.tools.doclets.standard; - -import com.sun.javadoc.RootDoc; -import com.sun.tools.doclets.MessageRetriever; - -import java.io.IOException; -import java.net.URL; -import java.util.Locale; -import java.util.MissingResourceException; -import java.util.PropertyResourceBundle; -import java.util.ResourceBundle; - -/** - * A customized configuration. - * - * @author Jeff Palm - */ -public class ConfigurationStandard - extends com.sun.tools.doclets.standard.ConfigurationStandard -{ - - /** It true we don't print crosscut information. */ - public boolean nocrosscuts = false; - - /** If true we don't print crosscut summary information. */ - public boolean nosummarycrosscuts = false; - - /** If true we log each pass in the doclet. */ - public boolean log = false; - - public ConfigurationStandard() { -// standardmessage = new MessageRetriever -// ("org.aspectj.tools.doclets.standard.resources.standard"); - - String loc = "org.aspectj.tools.doclets.standard.resources.standard"; - final ClassLoader loader = getClass().getClassLoader(); - // XXX move persistant resource loader to util - ResourceBundle bundle = null; - for (int i = 0; ((null == bundle) && (i < 4)); i++) { - - try { - switch (i) { - case 0: - bundle = ResourceBundle.getBundle(loc); - standardmessage = new MessageRetriever(bundle); - break; - case 1: - Locale locale = Locale.getDefault(); - bundle = ResourceBundle.getBundle(loc, locale, loader); - standardmessage = new MessageRetriever(bundle); - break; - case 2: - standardmessage = new MessageRetriever(loc); - break; - case 3: - URL pURL = loader.getResource(loc + ".properties"); - bundle = new PropertyResourceBundle(pURL.openStream()); - standardmessage = new MessageRetriever(loc); - break; - } - break; // from for loop - } catch (MissingResourceException e) { } // error below - catch (IOException ie) { } // error below - } - if (null == bundle) { - throw new Error("unable to load resource: " + loc); - } - } - - //TODO: Document the new options in help - - public void setSpecificDocletOptions(RootDoc root) { - String[][] options = root.options(); - for (int i = 0; i < options.length; ++i) { - String opt = options[i][0].toLowerCase(); - if (opt.equals("-nocrosscuts")) { - nocrosscuts = true; - nosummarycrosscuts = true; - } else if (opt.equals("-nosummarycrosscuts")) { - nosummarycrosscuts = true; - } else if (opt.equals("-log")) { - log = true; - } - } - super.setSpecificDocletOptions(root); - } - - public int specificDocletOptionLength(String opt) { - if (opt.equals("-nocrosscuts") || - opt.equals("-nosummarycrosscuts") || - opt.equals("-log")) { - return 1; - } - return super.specificDocletOptionLength(opt); - } -} - - diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/ConstructorIntroductionSubWriter.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/ConstructorIntroductionSubWriter.java deleted file mode 100644 index ad16055e0..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/ConstructorIntroductionSubWriter.java +++ /dev/null @@ -1,126 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.doclets.standard; - -import org.aspectj.ajdoc.AspectDoc; -import org.aspectj.ajdoc.IntroducedDoc; -import org.aspectj.ajdoc.IntroductionDoc; - -import com.sun.javadoc.ClassDoc; -import com.sun.javadoc.MemberDoc; -import com.sun.javadoc.ProgramElementDoc; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -public class ConstructorIntroductionSubWriter extends ConstructorSubWriter { - - public ConstructorIntroductionSubWriter - (com.sun.tools.doclets.standard.SubWriterHolderWriter writer, - AspectDoc ad) - { - super(writer, ad); - } - - public ConstructorIntroductionSubWriter - (com.sun.tools.doclets.standard.SubWriterHolderWriter writer) - { - super(writer); - } - - protected final String keyName() { return "Constructor_Introduction"; } - - protected List getMembers(ClassDoc cd) { - if (!(cd instanceof AspectDoc)) return super.getMembers(cd); - IntroductionDoc[] introductions = ((AspectDoc)cd).introductions(); - List list = new ArrayList(); - if (introductions == null) return list; - for (int i = 0; i < introductions.length; i++) { - IntroductionDoc id = introductions[i]; - if (!(id instanceof IntroducedDoc)) continue; - MemberDoc member = ((IntroducedDoc)id).member(); - if (member.isConstructor()) { - //ConstructorDec constructor = (ConstructorDec)member; - //TODO: constructor.bindSignatures(((ClassDec)cd).getTypeScope()); - list.add(member); //constructor); - } - } - return list; - } - - public void printCrosscuts(ClassDoc cd, ProgramElementDoc member) { - org.aspectj.ajdoc.ConstructorDoc constr = - (org.aspectj.ajdoc.ConstructorDoc)member; - IntroducedDoc intro = constr.introduced(); - //String name = where(constr); - ClassDoc[] targets = intro.targets(); - if (targets.length > 0) { - writer.dt(); - writer.boldText("doclet.Introduced_on"); - writer.dd(); - writer.code(); - for (int i = 0; i < targets.length; i++) { - if (i > 0) writer.print(", "); - ClassDoc target = targets[i]; - writer.printClassLink(target, - "constructors_introduced_from_class_" + - cd.qualifiedName(), - target.name()); - } - writer.codeEnd(); - writer.ddEnd(); // XXX added for balance - } - } - - public void printSummaryCrosscuts(ClassDoc cd, - ProgramElementDoc member) { - Set set = new HashSet(); - org.aspectj.ajdoc.MemberDoc md = (org.aspectj.ajdoc.MemberDoc)member; - IntroducedDoc intro = md.introduced(); - ClassDoc[] targets = intro.targets(); - for (int i = 0; i < targets.length; i++) { - set.add(targets[i]); - } - if (targets.length > 0) { - writer.boldText("doclet.Advises"); - List list = new ArrayList(set); - Collections.sort(list); - for (Iterator i = list.iterator(); i.hasNext();) { - print(' '); - ClassDoc target = (ClassDoc)i.next(); - writer.printClassLink(target, - "constructors_introduced_from_class_" - + cd.qualifiedName(), - target.name()); - if (i.hasNext()) print(","); - } - } - } - - public boolean hasCrosscuts(ClassDoc classDoc, ProgramElementDoc member) { - return true; - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/ConstructorSubWriter.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/ConstructorSubWriter.java deleted file mode 100644 index bd8360be5..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/ConstructorSubWriter.java +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.doclets.standard; - -import com.sun.javadoc.ClassDoc; -import com.sun.javadoc.ProgramElementDoc; -import com.sun.tools.doclets.VisibleMemberMap; - -public class ConstructorSubWriter extends ExecutableMemberSubWriter { - - public static class Del - extends com.sun.tools.doclets.standard.ConstructorSubWriter { - protected ConstructorSubWriter mw; - public Del(com.sun.tools.doclets.standard.SubWriterHolderWriter writer, - ClassDoc classdoc) { - super(writer, classdoc); - } - public Del(com.sun.tools.doclets.standard.SubWriterHolderWriter writer) - { - super(writer); - } - public void printMembersSummary() { - mw.printMembersSummary(); - mw.printIntroducedMembersSummary(); - } - public void printMembers() { - mw.printMembers(); - } - protected void navSummaryLink() { - mw.navSummaryLink(); - } - protected void navDetailLink() { - mw.navDetailLink(); - } - public void setDelegator(ConstructorSubWriter mw) { this.mw = mw; } - public void printSummaryMember(ClassDoc cd, ProgramElementDoc member) { - mw.printSummaryMember(cd, member); - } - } - - protected Class delegateClass() { - return Del.class; - } - - public ConstructorSubWriter - (com.sun.tools.doclets.standard.SubWriterHolderWriter writer, - ClassDoc classdoc) - { - super(writer, classdoc); - } - - public ConstructorSubWriter - (com.sun.tools.doclets.standard.SubWriterHolderWriter writer) - { - super(writer); - } - - public int getMemberKind() { - //XXX hack!!! - return VisibleMemberMap.CONSTRUCTORS; - } - - protected String propertyName() { return "Constructor"; } -} - - diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/DeprecatedAPIListBuilder.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/DeprecatedAPIListBuilder.java deleted file mode 100644 index bc90a0f24..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/DeprecatedAPIListBuilder.java +++ /dev/null @@ -1,120 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.doclets.standard; - -import org.aspectj.ajdoc.AspectDoc; -import org.aspectj.ajdoc.IntroducedDoc; -import org.aspectj.ajdoc.IntroductionDoc; -import org.aspectj.tools.ajdoc.Util; - -import com.sun.javadoc.ClassDoc; -import com.sun.javadoc.MemberDoc; -import com.sun.javadoc.RootDoc; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -public class DeprecatedAPIListBuilder - extends com.sun.tools.doclets.standard.DeprecatedAPIListBuilder -{ - - private List deprecatedadvice = new ArrayList(); - private List deprecatedpointcuts = new ArrayList(); - private List deprecatedfieldintroductions = new ArrayList(); - private List deprecatedmethodintroductions = new ArrayList(); - private List deprecatedconstructorintroductions = new ArrayList(); - private List deprecatedsuperintroductions = new ArrayList(); - - public DeprecatedAPIListBuilder(RootDoc root) { - super(root); - buildDeprecatedAPIInfo(root); - } - - protected void buildDeprecatedAPIInfo(RootDoc root) { - ClassDoc[] cs = root.classes(); - for (int i = 0; i < cs.length; i++) { - org.aspectj.ajdoc.ClassDoc c = (org.aspectj.ajdoc.ClassDoc)cs[i]; - _composeDeprecatedList(deprecatedpointcuts, c.pointcuts()); - if (c instanceof AspectDoc) { - AspectDoc ad = (AspectDoc)c; - _composeDeprecatedList(deprecatedadvice, ad.advice()); - IntroductionDoc[] intros = ad.introductions(); - for (int j = 0; j < intros.length; j++) { - if (intros[j] instanceof IntroducedDoc) { - MemberDoc md = ((IntroducedDoc)intros[j]).member(); - if (md == null) continue; - if (md.isField()) { - _composeDeprecatedList(deprecatedfieldintroductions, - intros[j]); - } else if (md.isMethod()) { - _composeDeprecatedList(deprecatedmethodintroductions, - intros[j]); - } else { - _composeDeprecatedList(deprecatedconstructorintroductions, - intros[j]); - } - } else { - _composeDeprecatedList(deprecatedsuperintroductions, - intros[j]); - } - } - } - } - Collections.sort(deprecatedadvice); - Collections.sort(deprecatedpointcuts); - Collections.sort(deprecatedfieldintroductions); - Collections.sort(deprecatedmethodintroductions); - Collections.sort(deprecatedconstructorintroductions); - Collections.sort(deprecatedsuperintroductions); - } - - protected void _composeDeprecatedList(List list, MemberDoc member) { - _composeDeprecatedList(list, new MemberDoc[]{member}); - } - protected void _composeDeprecatedList(List list, MemberDoc[] members) { - Util.invoke(com.sun.tools.doclets.standard.DeprecatedAPIListBuilder.class, - this, "composeDeprecatedList", - new Class[]{java.util.List.class, - com.sun.javadoc.MemberDoc[].class}, - new Object[]{list, members}); - } - - public List getDeprecatedAdivce() { - return deprecatedadvice; - } - public List getDeprecatedPointcuts() { - return deprecatedpointcuts; - } - public List getDeprecatedFieldIntroductions() { - return deprecatedfieldintroductions; - } - public List getDeprecatedMethodIntroductions() { - return deprecatedmethodintroductions; - } - public List getDeprecatedConstructorIntroductions() { - return deprecatedconstructorintroductions; - } - public List getDeprecatedSuperIntroductions() { - return deprecatedsuperintroductions; - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/DeprecatedListWriter.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/DeprecatedListWriter.java deleted file mode 100644 index 8333b6569..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/DeprecatedListWriter.java +++ /dev/null @@ -1,94 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.doclets.standard; - -import org.aspectj.tools.ajdoc.Access; - -import com.sun.javadoc.RootDoc; -import com.sun.tools.doclets.DocletAbortException; - -import java.io.IOException; -import java.util.List; - -public class DeprecatedListWriter - extends com.sun.tools.doclets.standard.DeprecatedListWriter -{ - - protected DeprecatedAPIListBuilder builder; - - public DeprecatedListWriter(String filename, - DeprecatedAPIListBuilder builder) - throws IOException { - super(filename); - this.builder = builder; - } - - public static void generate(RootDoc root) throws DocletAbortException { - String filename = "deprecated-list.html"; - DeprecatedListWriter dw = null; - try { - (dw = new DeprecatedListWriter(filename, - new DeprecatedAPIListBuilder(root))). - generateDeprecatedListFile(); - } catch (IOException e) { - Standard.configuration(). - standardmessage.error("doclet.exception_encountered", - e+"", filename); - throw new DocletAbortException(); - } finally { - if (dw != null) dw.close(); - } - } - - protected void generateDeprecatedListFile() throws IOException { - generateDeprecatedListFile(builder); - } - - protected void printDeprecatedFooter() { - printRestOfDeprecatedListFile(); - super.printDeprecatedFooter(); - } - - protected void printRestOfDeprecatedListFile() { - deprecatedListFile(new AdviceSubWriter(this), - builder.getDeprecatedAdivce()); - deprecatedListFile(new PointcutSubWriter(this), - builder.getDeprecatedPointcuts()); - deprecatedListFile(new FieldIntroductionSubWriter(this), - builder.getDeprecatedFieldIntroductions()); - deprecatedListFile(new MethodIntroductionSubWriter(this), - builder.getDeprecatedMethodIntroductions()); - deprecatedListFile(new ConstructorIntroductionSubWriter(this), - builder.getDeprecatedConstructorIntroductions()); - deprecatedListFile(new SuperIntroductionSubWriter(this), - builder.getDeprecatedSuperIntroductions()); - - - } - - protected final void deprecatedListFile(AbstractSubWriter mw, - List list) { - Access.printDeprecatedAPI(mw, list, - "doclet.Deprecated_" + - mw.keyName() + "s"); - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/ExecutableMemberSubWriter.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/ExecutableMemberSubWriter.java deleted file mode 100644 index 12e57853c..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/ExecutableMemberSubWriter.java +++ /dev/null @@ -1,139 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.doclets.standard; - -import org.aspectj.ajdoc.AdviceDoc; -import org.aspectj.ajdoc.IntroducedDoc; - -import com.sun.javadoc.ClassDoc; -import com.sun.javadoc.ExecutableMemberDoc; -import com.sun.javadoc.ProgramElementDoc; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -public abstract class ExecutableMemberSubWriter extends AbstractSubWriter { - public ExecutableMemberSubWriter - (com.sun.tools.doclets.standard.SubWriterHolderWriter writer, - ClassDoc classdoc) - { - super(writer, classdoc); - } - - public ExecutableMemberSubWriter - (com.sun.tools.doclets.standard.SubWriterHolderWriter writer) - { - super(writer); - } - - protected String where(ProgramElementDoc member) { - ExecutableMemberDoc emd = (ExecutableMemberDoc)member; - return emd.name() + emd.signature(); - } - - protected String label(ExecutableMemberDoc emd) { - return emd.qualifiedName() + emd.flatSignature(); - } - - public void printIntroducedSummaryLink(ClassDoc cd, - ProgramElementDoc member) { - ExecutableMemberDoc emd = (ExecutableMemberDoc)member; - writer.printClassLink(cd, where(emd), emd.name(), false); - } - - public void printCrosscuts(ClassDoc cd, ProgramElementDoc member) { - org.aspectj.ajdoc.ExecutableMemberDoc emd = - (org.aspectj.ajdoc.ExecutableMemberDoc)member; - - IntroducedDoc intro = emd.introduced(); - if (intro != null) { - writer.dt(); - writer.boldText("doclet.Introduced_from"); - writer.dd(); - org.aspectj.ajdoc.MemberDoc otherMember = - (org.aspectj.ajdoc.MemberDoc)intro.member(); - String name = where(otherMember); - ClassDoc containing = intro.containingClass(); - writer.printClassLink(containing, name, - containing.typeName(), false); - } - - AdviceDoc[] advice = emd.advice(); - if (advice.length > 0) { - writer.boldText("doclet.Crosscut_by"); - Set set = new HashSet(); - for (int i = 0; i < advice.length; i++) { - set.add(advice[i]); - } - List list = new ArrayList(set); - Collections.sort(list); - for (Iterator i = list.iterator(); i.hasNext();) { - writer.dd(); - writer.code(); - AdviceDoc ad = (AdviceDoc)i.next(); - writer.printClassLink(ad.containingClass(), - AdviceSubWriter.getWhere - (ad.containingClass(), ad), - label(ad)); - print(" in "); - writer.printClassLink(ad.containingClass()); - writer.codeEnd(); - print('.'); - } - } - } - - public void printSummaryCrosscuts(ClassDoc cd, - ProgramElementDoc member) { - Set cds = new HashSet(); - org.aspectj.ajdoc.ExecutableMemberDoc emd = - (org.aspectj.ajdoc.ExecutableMemberDoc)member; - AdviceDoc[] advice = emd.advice(); - for (int i = 0; i < advice.length; i++) { - cds.add(advice[i].containingClass()); - } - if (cds.size() > 0) { - writer.boldText("doclet.Advised_by"); - List list = new ArrayList(cds); - Collections.sort(list); - for (Iterator i = list.iterator(); i.hasNext();) { - print(' '); - ClassDoc cdoc = (ClassDoc)i.next(); - writer.printClassLink(cdoc, "advice_detail", cdoc.name()); - if (i.hasNext()) print(","); - } - } - } - - public boolean hasCrosscuts(ClassDoc classDoc, - ProgramElementDoc member) { - org.aspectj.ajdoc.ExecutableMemberDoc emd = - (org.aspectj.ajdoc.ExecutableMemberDoc)member; - return emd.introduced() != null || emd.advice().length > 0; - } -} - - diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/FieldIntroductionSubWriter.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/FieldIntroductionSubWriter.java deleted file mode 100644 index fd7519bf7..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/FieldIntroductionSubWriter.java +++ /dev/null @@ -1,131 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.doclets.standard; -import org.aspectj.ajdoc.AspectDoc; -import org.aspectj.ajdoc.IntroducedDoc; -import org.aspectj.ajdoc.IntroductionDoc; - -import com.sun.javadoc.ClassDoc; -import com.sun.javadoc.MemberDoc; -import com.sun.javadoc.ProgramElementDoc; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -public class FieldIntroductionSubWriter extends FieldSubWriter { - - public FieldIntroductionSubWriter - (com.sun.tools.doclets.standard.SubWriterHolderWriter writer, - AspectDoc ad) - { - super(writer, ad); - } - - public FieldIntroductionSubWriter - (com.sun.tools.doclets.standard.SubWriterHolderWriter writer) - { - super(writer); - } - - protected final String keyName() { return "Field_Introduction"; } - - public void printInheritedSummaryAnchor(ClassDoc cd) {} - public void printInheritedSummaryLabel(ClassDoc cd) {} - protected void printInheritedSummaryLink(ClassDoc cd, ProgramElementDoc ped) {} - - protected List getMembers(ClassDoc cd) { - if (!(cd instanceof AspectDoc)) return super.getMembers(cd); - IntroductionDoc[] introductions = ((AspectDoc)cd).introductions(); - List list = new ArrayList(); - if (introductions == null) return list; - for (int i = 0; i < introductions.length; i++) { - IntroductionDoc id = introductions[i]; - if (!(id instanceof IntroducedDoc)) continue; - MemberDoc member = ((IntroducedDoc)id).member(); - if (member.isField()) { - //FieldDec field = (FieldDec)member; - //TODO: field.bindSignatures(((ClassDec)cd).getTypeScope()); - list.add(member); //field); - } - } - return list; - } - - /** print links back to aspect in target class docs? - * or forward from aspects to target class members? */ - public void printCrosscuts(ClassDoc cd, ProgramElementDoc member) { - org.aspectj.ajdoc.FieldDoc field = (org.aspectj.ajdoc.FieldDoc)member; - IntroducedDoc intro = field.introduced(); - //String name = field.name(); - ClassDoc[] targets = intro.targets(); - if (targets.length > 0) { - writer.dt(); // define term - writer.boldText("doclet.Introduced_on"); - writer.dd(); - writer.code(); - for (int i = 0; i < targets.length; i++) { - if (i > 0) writer.print(", "); - ClassDoc target = targets[i]; - writer.printClassLink(target, - "fields_introduced_from_class_" + - cd.qualifiedName(), - target.name()); - - } - writer.codeEnd(); - writer.ddEnd(); // XXX added for balance - } - } - - public void printSummaryCrosscuts(ClassDoc cd, - ProgramElementDoc member) { - Set set = new HashSet(); - org.aspectj.ajdoc.MemberDoc md = (org.aspectj.ajdoc.MemberDoc)member; - IntroducedDoc intro = md.introduced(); - ClassDoc[] targets = intro.targets(); - for (int i = 0; i < targets.length; i++) { - set.add(targets[i]); - } - if (targets.length > 0) { - writer.boldText("doclet.Advises"); - List list = new ArrayList(set); - Collections.sort(list); - for (Iterator i = list.iterator(); i.hasNext();) { - print(' '); - ClassDoc target = (ClassDoc)i.next(); - writer.printClassLink(target, - "fields_introduced_from_class_" - + cd.qualifiedName(), - target.name()); - if (i.hasNext()) print(","); - } - } - } - - public boolean hasCrosscuts(ClassDoc classDoc, ProgramElementDoc member) { - return true; - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/FieldSubWriter.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/FieldSubWriter.java deleted file mode 100644 index cca7b6510..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/FieldSubWriter.java +++ /dev/null @@ -1,116 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.doclets.standard; - -import org.aspectj.ajdoc.IntroducedDoc; - -import com.sun.javadoc.ClassDoc; -import com.sun.javadoc.ProgramElementDoc; -import com.sun.tools.doclets.VisibleMemberMap; - -public class FieldSubWriter extends AbstractSubWriter { - - public static class Del extends com.sun.tools.doclets.standard.FieldSubWriter { - protected FieldSubWriter mw; - public Del(com.sun.tools.doclets.standard.SubWriterHolderWriter writer, - ClassDoc classdoc) - { - super(writer, classdoc); - } - public Del(com.sun.tools.doclets.standard.SubWriterHolderWriter writer) - { - super(writer); - } - public void printMembersSummary() { - mw.printMembersSummary(); - mw.printIntroducedMembersSummary(); - } - public void printMembers() { - if (writer instanceof ClassWriter) { - ((ClassWriter)writer).printAspectJDetail(); - } - mw.printMembers(); - } - protected void navSummaryLink() { - mw.navSummaryLink(); - } - protected void navDetailLink() { - if (writer instanceof ClassWriter) { - ((ClassWriter)writer).navstate++; - } - mw.navDetailLink(); - } - public void setDelegator(FieldSubWriter mw) { this.mw = mw; } - public void printSummaryMember(ClassDoc cd, ProgramElementDoc member) { - mw.printSummaryMember(cd, member); - } - } - - protected Class delegateClass() { - return Del.class; - } - - public FieldSubWriter - (com.sun.tools.doclets.standard.SubWriterHolderWriter writer, - ClassDoc classdoc) - { - super(writer, classdoc); - } - - public FieldSubWriter - (com.sun.tools.doclets.standard.SubWriterHolderWriter writer) - { - super(writer); - } - - public int getMemberKind() { - //XXX hack!!! - return VisibleMemberMap.FIELDS; - } - - protected String propertyName() { return "Field"; } - - public void printIntroducedSummaryLink(ClassDoc cd, - ProgramElementDoc member) { - writer.printClassLink(cd, member.name(), member.name(), false); - } - - public void printCrosscuts(ClassDoc cd, ProgramElementDoc member) { - org.aspectj.ajdoc.FieldDoc field = (org.aspectj.ajdoc.FieldDoc)member; - IntroducedDoc intro = field.introduced(); - if (intro != null) { - writer.dt(); - writer.boldText("doclet.Introduced_from"); - writer.dd(); - writer.printClassLink(intro.containingClass(), - Statics.where(intro.member())); - } - } - - public void printSummaryCrosscuts(ClassDoc cd, ProgramElementDoc member) {} - - public boolean hasCrosscuts(ClassDoc classDoc, ProgramElementDoc member) { - return true || ((org.aspectj.ajdoc.MemberDoc)member).introduced() != null; - } -} - - diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/MethodIntroductionSubWriter.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/MethodIntroductionSubWriter.java deleted file mode 100644 index ba28e4f34..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/MethodIntroductionSubWriter.java +++ /dev/null @@ -1,136 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.doclets.standard; -import org.aspectj.ajdoc.AspectDoc; -import org.aspectj.ajdoc.IntroducedDoc; -import org.aspectj.ajdoc.IntroductionDoc; - -import com.sun.javadoc.ClassDoc; -import com.sun.javadoc.MemberDoc; -import com.sun.javadoc.ProgramElementDoc; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -public class MethodIntroductionSubWriter extends MethodSubWriter { - - public MethodIntroductionSubWriter - (com.sun.tools.doclets.standard.SubWriterHolderWriter writer, - AspectDoc ad) - { - super(writer, ad); - } - - public MethodIntroductionSubWriter - (com.sun.tools.doclets.standard.SubWriterHolderWriter writer) - { - super(writer); - } - - protected final String keyName() { return "Method_Introduction"; } - - public void printInheritedSummaryAnchor(ClassDoc cd) {} - public void printInheritedSummaryLabel(ClassDoc cd) {} - protected void printInheritedSummaryLink(ClassDoc cd, ProgramElementDoc ped) {} - - protected List getMembers(ClassDoc cd) { - if (!(cd instanceof AspectDoc)) return super.getMembers(cd); - IntroductionDoc[] introductions = ((AspectDoc)cd).introductions(); - List list = new ArrayList(); - if (introductions == null) return list; - for (int i = 0; i < introductions.length; i++) { - IntroductionDoc id = introductions[i]; - if (!(id instanceof IntroducedDoc)) continue; - MemberDoc member = ((IntroducedDoc)id).member(); - if (member.isMethod()) { - //MethodDec method = (MethodDec)member; - //TODO: method.bindSignatures(((ClassDec)cd).getTypeScope()); - list.add(member); //method); - } - } - return list; - } - - /** print in the detail context at the bottom of the page - * the links out to affected classes/members for this method introduction - * (in this aspect) - */ - public void printCrosscuts(ClassDoc cd, ProgramElementDoc member) { - org.aspectj.ajdoc.MethodDoc method = (org.aspectj.ajdoc.MethodDoc)member; - IntroducedDoc intro = method.introduced(); - ClassDoc[] targets = intro.targets(); - if (targets.length > 0) { - writer.dt(); - writer.boldText("doclet.Introduced_on"); - writer.dd(); - writer.code(); - for (int i = 0; i < targets.length; i++) { - if (i > 0) writer.print(", "); - ClassDoc target = targets[i]; - writer.printClassLink(target, - "methods_introduced_from_class_" + - cd.qualifiedName(), - target.name()); - } - writer.codeEnd(); - writer.ddEnd(); // XXX added for balance - } - } - - /** print in the summary context at the top of the page - * the links out to affected classes/members for this method introduction - * (in this aspect) - */ - public void printSummaryCrosscuts(ClassDoc cd, - ProgramElementDoc member) { - Set set = new HashSet(); - org.aspectj.ajdoc.MemberDoc md = (org.aspectj.ajdoc.MemberDoc)member; - IntroducedDoc intro = md.introduced(); - ClassDoc[] targets = intro.targets(); - for (int i = 0; i < targets.length; i++) { - set.add(targets[i]); - } - if (targets.length > 0) { - writer.boldText("doclet.Advises"); - List list = new ArrayList(set); - Collections.sort(list); - for (Iterator i = list.iterator(); i.hasNext();) { - print(' '); - ClassDoc target = (ClassDoc)i.next(); - - writer.printClassLink(target, - "methods_introduced_from_class_" - + cd.qualifiedName(), - target.name()); - if (i.hasNext()) print(","); - } - } - } - - public boolean hasCrosscuts(ClassDoc classDoc, ProgramElementDoc member) { - return true; - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/MethodSubWriter.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/MethodSubWriter.java deleted file mode 100644 index 31473e0e3..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/MethodSubWriter.java +++ /dev/null @@ -1,112 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.doclets.standard; - -import org.aspectj.ajdoc.AdviceDoc; - -import com.sun.javadoc.ClassDoc; -import com.sun.javadoc.ExecutableMemberDoc; -import com.sun.javadoc.MethodDoc; -import com.sun.javadoc.ProgramElementDoc; -import com.sun.tools.doclets.VisibleMemberMap; - -public class MethodSubWriter extends ExecutableMemberSubWriter { - - public static class Del - extends com.sun.tools.doclets.standard.MethodSubWriter { - protected MethodSubWriter mw; - public Del(com.sun.tools.doclets.standard.SubWriterHolderWriter writer, - ClassDoc classdoc) - { - super(writer, classdoc); - } - public Del(com.sun.tools.doclets.standard.SubWriterHolderWriter writer) - { - super(writer); - } - public void printMembersSummary() { - mw.printMembersSummary(); - mw.printIntroducedMembersSummary(); - } - public void printMembers() { - mw.printMembers(); - } - protected void navSummaryLink() { - mw.navSummaryLink(); - } - protected void navDetailLink() { - mw.navDetailLink(); - } - public void setDelegator(MethodSubWriter mw) { this.mw = mw; } - public void printSummaryMember(ClassDoc cd, ProgramElementDoc member) { - mw.printSummaryMember(cd, member); - } - } - - protected Class delegateClass() { return Del.class; } - - public MethodSubWriter - (com.sun.tools.doclets.standard.SubWriterHolderWriter writer, - ClassDoc classdoc) - { - super(writer, classdoc); - } - - public MethodSubWriter - (com.sun.tools.doclets.standard.SubWriterHolderWriter writer) - { - super(writer); - } - - public int getMemberKind() { - //XXX hack!!! - return VisibleMemberMap.METHODS; - } - - //XXX - //hacks - protected void printSummaryType(ProgramElementDoc member) { - if (member instanceof MethodDoc) { - //TODO: Put in Access... - MethodDoc meth = (MethodDoc)member; - printModifierAndType(meth, meth.returnType()); - } else if (member instanceof AdviceDoc) { - AdviceDoc advice = (AdviceDoc)member; - printModifierAndType(advice, advice.returnType()); - } - } - protected void printSignature(ExecutableMemberDoc member) { - writer.displayLength = 0; - writer.pre(); - printModifiers(member); - //printReturnType((MethodDoc)member); - bold(member.name()); - // printParameters(member); - // printExceptions(member); - writer.preEnd(); - } - //end-hacks - - protected String propertyName() { return "Method"; } -} - - diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/PackageFrameWriter.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/PackageFrameWriter.java deleted file mode 100644 index c49cbc015..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/PackageFrameWriter.java +++ /dev/null @@ -1,75 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.doclets.standard; - -import com.sun.javadoc.PackageDoc; -import com.sun.tools.doclets.DirectoryManager; -import com.sun.tools.doclets.DocletAbortException; - -import java.io.IOException; - -public class PackageFrameWriter - extends com.sun.tools.doclets.standard.PackageFrameWriter -{ - - protected final PackageDoc packagedoc; - - public PackageFrameWriter(String path, - String filename, - PackageDoc packagedoc) - throws IOException, DocletAbortException { - super(path, filename, packagedoc); - this.packagedoc = packagedoc; - } - - public static void generate(PackageDoc pkg) throws DocletAbortException { - PackageFrameWriter pw = null; - String path = DirectoryManager.getDirectoryPath(pkg); - String filename = "package-frame" + ".html"; - try { - (pw = new PackageFrameWriter(path, filename, pkg)). - generatePackageFile(); - } catch (IOException e) { - Standard.configuration().standardmessage. - error("doclet.exception_encountered", - e+"", filename); - throw new DocletAbortException(); - } finally { - if (pw != null) pw.close(); - } - } - - protected void generateClassListing() { - generateClassKindListing(packagedoc.interfaces(), - getText("doclet.Interfaces")); - generateClassKindListing(Statics.classes(packagedoc. - ordinaryClasses()), - getText("doclet.Classes")); - generateClassKindListing(((org.aspectj.ajdoc.PackageDoc)packagedoc). - aspects(), - getText("doclet.Aspects")); - generateClassKindListing(packagedoc.exceptions(), - getText("doclet.Exceptions")); - generateClassKindListing(packagedoc.errors(), - getText("doclet.Errors")); - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/PackageTreeWriter.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/PackageTreeWriter.java deleted file mode 100644 index 161608e44..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/PackageTreeWriter.java +++ /dev/null @@ -1,97 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.doclets.standard; - -import com.sun.javadoc.ClassDoc; -import com.sun.javadoc.PackageDoc; -import com.sun.tools.doclets.ClassTree; -import com.sun.tools.doclets.DirectoryManager; -import com.sun.tools.doclets.DocletAbortException; - -import java.io.IOException; -import java.util.List; - -public class PackageTreeWriter - extends com.sun.tools.doclets.standard.PackageTreeWriter -{ - - protected class Del extends AbstractTreeWriter { - public Del(String s, ClassTree c) - throws IOException, DocletAbortException { - super(s, c); - } - public void print(String s) { - PackageTreeWriter.this.print(s); - } - } - final protected Del del; - { - Standard.quiet(); - Del d = null; - try { - d = new Del(filename, classtree); - } catch (Exception e) { - Standard.configuration().standardmessage. - error("doclet.exception_encountered", - e+"", filename); - } finally { - del = d; - Standard.speak(); - } - } - protected void generateLevelInfo(ClassDoc parent, List list) { - del.generateLevelInfo(parent, list); - } - protected void generateTree(List list, String heading) { - del.generateTree(list, heading); - } - - public PackageTreeWriter(String path, - String filename, - PackageDoc packagedoc, - PackageDoc prev, - PackageDoc next, - boolean noDeprecated) - throws IOException, DocletAbortException { - super(path, filename, packagedoc, prev, next, noDeprecated); - } - - public static void generate(PackageDoc pkg, PackageDoc prev, - PackageDoc next, boolean noDeprecated) - throws DocletAbortException { - PackageTreeWriter pw = null; - String path = DirectoryManager.getDirectoryPath(pkg); - String filename = "package-tree.html"; - try { - (pw = new PackageTreeWriter(path, filename, pkg, - prev, next, noDeprecated)). - generatePackageTreeFile(); - } catch (IOException e) { - Standard.configuration().standardmessage. - error("doclet.exception_encountered", - e+"", filename); - throw new DocletAbortException(); - } finally { - if (pw != null) pw.close(); - } - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/PackageWriter.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/PackageWriter.java deleted file mode 100644 index 8a6ed5e57..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/PackageWriter.java +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.doclets.standard; - -import com.sun.javadoc.PackageDoc; -import com.sun.tools.doclets.DirectoryManager; -import com.sun.tools.doclets.DocletAbortException; - -import java.io.IOException; - -public class PackageWriter - extends com.sun.tools.doclets.standard.PackageWriter -{ - - protected final PackageDoc packagedoc; - - public PackageWriter(String path, - String filename, - PackageDoc packagedoc, - PackageDoc prev, - PackageDoc next) - throws IOException, DocletAbortException { - super(path, filename, packagedoc, prev, next); - this.packagedoc = packagedoc; - } - - public static void generate(PackageDoc pkg, - PackageDoc prev, - PackageDoc next) throws DocletAbortException { - PackageWriter pw; - String path = DirectoryManager.getDirectoryPath(pkg); - String filename = "package-summary.html"; - try { - (pw = new PackageWriter(path, filename, pkg, prev, next)). - generatePackageFile(); - pw.close(); - pw.copyDocFiles(path); - } catch (IOException e) { - Standard.configuration().standardmessage. - error("doclet.exception_encountered", e+"", filename); - throw new DocletAbortException(); - } - } - - protected void generateClassListing() { - generateClassKindListing(packagedoc.interfaces(), - getText("doclet.Interface_Summary")); - generateClassKindListing(Statics.classes(packagedoc.ordinaryClasses()), - getText("doclet.Class_Summary")); - generateClassKindListing(((org.aspectj.ajdoc.PackageDoc)packagedoc).aspects(), - getText("doclet.Aspect_Summary")); - generateClassKindListing(packagedoc.exceptions(), - getText("doclet.Exception_Summary")); - generateClassKindListing(packagedoc.errors(), - getText("doclet.Error_Summary")); - } -} - - - diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/PointcutSubWriter.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/PointcutSubWriter.java deleted file mode 100644 index 518c9f2ca..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/PointcutSubWriter.java +++ /dev/null @@ -1,227 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.doclets.standard; -import org.aspectj.ajdoc.PointcutDoc; - -import com.sun.javadoc.ClassDoc; -import com.sun.javadoc.MemberDoc; -import com.sun.javadoc.ParamTag; -import com.sun.javadoc.Parameter; -import com.sun.javadoc.ProgramElementDoc; -import com.sun.javadoc.SeeTag; -import com.sun.javadoc.Tag; -import com.sun.javadoc.Type; -import com.sun.tools.doclets.Util; - -import java.util.List; - -public class PointcutSubWriter extends AbstractSubWriter { - - protected Class delegateClass() { - return null; - } - - public PointcutSubWriter - (com.sun.tools.doclets.standard.SubWriterHolderWriter writer, - ClassDoc classdoc) - { - super(writer, classdoc); - } - - public PointcutSubWriter - (com.sun.tools.doclets.standard.SubWriterHolderWriter writer) - { - super(writer); - } - - protected final String keyName() { return "Pointcut"; } - -// public void printInheritedSummaryAnchor(ClassDoc cd) { -// writer.anchor("pointcuts_inherited_from_class_" + cd.qualifiedName()); -// } - -// public void printInheritedSummaryLabel(ClassDoc cd) { -// String classlink = writer.getPreQualifiedClassLink(cd); -// writer.bold(); -// writer.printText("doclet.Pointcuts_Inherited_From", -// Statics.type(cd), -// classlink); -// writer.boldEnd(); -// } - - void printSignature(MemberDoc member) { - PointcutDoc pcd = (PointcutDoc)member; - writer.displayLength = 0; - writer.pre(); - printModifiers(pcd); - bold(pcd.name()); - printParameters(pcd); - printResultType(pcd); - writer.preEnd(); - } - - void printResultType(PointcutDoc pcd) { - Type result = pcd.resultType(); - if (result != null) { - writer.code(); - print(" returns "); - printTypeLink(result); - writer.codeEnd(); - } - } - - protected void printSummaryLink(ClassDoc cd, ProgramElementDoc member) { - PointcutDoc pcd = (PointcutDoc)member; - String name = member.name(); - writer.bold(); - writer.printClassLink(cd, name + pcd.signature(), name, false); - writer.boldEnd(); - writer.displayLength = name.length(); - printParameters(pcd); - printResultType(pcd); - - } - - protected void printInheritedSummaryLink(ClassDoc cd, - ProgramElementDoc member) { - PointcutDoc pcd = (PointcutDoc)member; - String name = member.name(); - writer.printClassLink(cd, name + pcd.signature(), name, false); - } - - protected void printSummaryType(ProgramElementDoc member) { - PointcutDoc pcd = (PointcutDoc)member; - writer.printTypeSummaryHeader(); - printModifier(pcd); - writer.printTypeSummaryFooter(); - - } - - protected void printBodyHtmlEnd(ClassDoc cd) { - } - - protected void nonfinalPrintMember(ProgramElementDoc member) { - PointcutDoc pcd = (PointcutDoc)member; - writer.anchor(pcd.name() + pcd.signature()); - printHead(pcd); - printSignature(pcd); - printFullComment(pcd); - } - - protected void printDeprecatedLink(ProgramElementDoc member) { - writer.printClassLink(member.containingClass(), - member.name(), - ((PointcutDoc)member).qualifiedName()); - } - - protected List getMembers(ClassDoc cd) { - return Util.asList(((org.aspectj.ajdoc.ClassDoc)cd).pointcuts()); - } - - protected void printParameters(PointcutDoc member) { - print('('); - Parameter[] params = member.parameters(); - for (int i = 0; i < params.length; i++) { - printParam(params[i]); - if (i < params.length-1) { - writer.print(','); - writer.print(' '); - } - } - writer.print(')'); - } - - protected void printParam(Parameter param) { - printTypedName(param.type(), param.name()); - } - - protected void printParamTags(ParamTag[] params) { - if (params.length > 0) { - writer.dt(); - writer.boldText("doclet.Parameters"); - for (int i = 0; i < params.length; ++i) { - ParamTag pt = params[i]; - writer.dd(); - writer.code(); - print(pt.parameterName()); - writer.codeEnd(); - print(" - "); - writer.printInlineComment(pt); - } - } - } - - protected void printReturnTag(Tag[] returnsTag) { - if (returnsTag.length > 0) { - writer.dt(); - writer.boldText("doclet.Returns"); - writer.dd(); - writer.printInlineComment(returnsTag[0]); - } - } - - protected void printOverridden(ClassDoc overridden, PointcutDoc pcd) { - if (overridden != null) { - String name = pcd.name(); - writer.dt(); - writer.boldText("doclet.Overrides"); - writer.dd(); - writer.printText("doclet.in_class", - writer.codeText - (writer.getClassLink(overridden, - name + pcd.signature(), - name, false)), - writer.codeText - (writer.getClassLink(overridden))); - } - } - - protected void printTags(ProgramElementDoc member) { - PointcutDoc pcd = (PointcutDoc)member; - ParamTag[] params = pcd.paramTags(); - Tag[] returnsTag = pcd.tags("return"); - Tag[] sinces = pcd.tags("since"); - SeeTag[] sees = pcd.seeTags(); - ClassDoc[] intfacs = member.containingClass().interfaces(); - ClassDoc overridden = pcd.overriddenClass(); - if (intfacs.length > 0 || overridden != null) { - writer.dd(); - writer.dl(); - printOverridden(overridden, pcd); - writer.dlEnd(); - writer.ddEnd(); - } - if (params.length + - returnsTag.length + - sinces.length + - sees.length > 0) { - writer.dd(); - writer.dl(); - printParamTags(params); - printReturnTag(returnsTag); - writer.printSinceTag(pcd); - writer.printSeeTags(pcd); - writer.dlEnd(); - writer.ddEnd(); - } - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/SingleIndexWriter.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/SingleIndexWriter.java deleted file mode 100644 index 889cfbbb8..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/SingleIndexWriter.java +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.doclets.standard; - -import com.sun.javadoc.MemberDoc; - -import com.sun.javadoc.ClassDoc; -import com.sun.tools.doclets.DocletAbortException; -import com.sun.tools.doclets.IndexBuilder; - -import java.io.IOException; - -public class SingleIndexWriter - extends com.sun.tools.doclets.standard.SingleIndexWriter -{ - - protected class Del extends AbstractIndexWriter { - public Del(String s, IndexBuilder i) throws IOException { - super(s, i); - } - public void print(String s) { - SingleIndexWriter.this.print(s); - } - } - final protected Del del; - { - Standard.quiet(); - Del d = null; - try { - d = new Del(filename, indexbuilder); - } catch (Exception e) { - Standard.configuration().standardmessage. - error("doclet.exception_encountered", - e+"", filename); - } finally { - del = d; - Standard.speak(); - } - } - protected void printMemberDesc(MemberDoc member) { - del.printMemberDesc(member); - } - protected void printClassInfo(ClassDoc cd) { - del.printClassInfo(cd); - } - - public SingleIndexWriter(String filename, - IndexBuilder indexbuilder) throws IOException { - super(filename, indexbuilder); - } - - public static void generate(IndexBuilder indexbuilder) - throws DocletAbortException { - SingleIndexWriter sw = null; - String filename = "index-all.html"; - try { - (sw = new SingleIndexWriter(filename, indexbuilder)). - generateIndexFile(); - } catch (IOException e) { - Standard.configuration().standardmessage.error - ("doclet.exception_encountered", - e+"", filename); - throw new DocletAbortException(); - } finally { - if (sw != null) sw.close(); - } - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/SplitIndexWriter.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/SplitIndexWriter.java deleted file mode 100644 index ea6e11204..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/SplitIndexWriter.java +++ /dev/null @@ -1,99 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.doclets.standard; - -import com.sun.javadoc.ClassDoc; -import com.sun.javadoc.MemberDoc; -import com.sun.tools.doclets.DirectoryManager; -import com.sun.tools.doclets.DocletAbortException; -import com.sun.tools.doclets.IndexBuilder; - -import java.io.IOException; - -public class SplitIndexWriter - extends com.sun.tools.doclets.standard.SplitIndexWriter -{ - - protected class Del extends AbstractIndexWriter { - public Del(String s, IndexBuilder i) throws IOException { - super(s, i); - } - public void print(String s) { - SplitIndexWriter.this.print(s); - } - } - final protected Del del; - { - Standard.quiet(); - Del d = null; - try { - d = new Del(filename, indexbuilder); - } catch (Exception e) { - Standard.configuration().standardmessage. - error("doclet.exception_encountered", - e+"", filename); - } finally { - del = d; - Standard.speak(); - } - } - protected void printMemberDesc(MemberDoc member) { - del.printMemberDesc(member); - } - protected void printClassInfo(ClassDoc cd) { - del.printClassInfo(cd); - } - - public SplitIndexWriter(String path, String filename, - String relpath, IndexBuilder indexbuilder, - int prev, int next) throws IOException { - super(path, filename, relpath, - indexbuilder, prev, next); - } - - public static void generate(IndexBuilder indexbuilder) - throws DocletAbortException { - SplitIndexWriter sw = null; - String filename = ""; - String path = DirectoryManager.getPath("index-files"); - String relpath = DirectoryManager.getRelativePath("index-files"); - try { - for (int i = 0; i < indexbuilder.elements().length; i++) { - int j = i + 1; - int prev = (j == 1)? -1: i; - int next = (j == indexbuilder.elements().length)? -1: j + 1; - filename = "index-" + j +".html"; - (sw = new SplitIndexWriter(path, filename, relpath, - indexbuilder, prev, next)). - generateIndexFile((Character) - indexbuilder.elements()[i]); - } - } catch (IOException e) { - Standard.configuration(). - standardmessage.error("doclet.exception_encountered", - e+"", filename); - throw new DocletAbortException(); - } finally { - if (sw != null) sw.close(); - } - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/Standard.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/Standard.java deleted file mode 100644 index 916336eb7..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/Standard.java +++ /dev/null @@ -1,251 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.doclets.standard; - -import org.aspectj.tools.ajdoc.Quietable; - -import com.sun.javadoc.RootDoc; -import com.sun.tools.doclets.DocletAbortException; -import com.sun.tools.doclets.standard.AllClassesFrameWriter; -import com.sun.tools.doclets.standard.FrameOutputWriter; -import com.sun.tools.doclets.standard.HelpWriter; -import com.sun.tools.doclets.standard.PackageIndexFrameWriter; -import com.sun.tools.doclets.standard.PackageIndexWriter; -import com.sun.tools.doclets.standard.PackageListWriter; -import com.sun.tools.doclets.standard.PackagesFileWriter; -import com.sun.tools.doclets.standard.SerializedFormWriter; -import com.sun.tools.doclets.standard.StylesheetWriter; - -import java.io.IOException; - -/** - * Main doclet for ajdoc. It defines a number of - * passes to use in generating the documentation. - * - * @author Jeff Palm - */ -public class Standard extends AbstractStandard { - private static Standard SINGLETON; // todo: prefer early/final? - public static final Standard getSingleton() { - if (null == SINGLETON) { - SINGLETON = new Standard(); - } - return SINGLETON; - } - private Standard() {} - - public static boolean start(RootDoc root) throws IOException { - return start(getSingleton(), root); - } - - public ConfigurationStandard getConfiguration() { - return (ConfigurationStandard)configuration(); - } - - public static void quiet() { - if (configuration().root instanceof Quietable) { - ((Quietable)configuration().root).quiet(); - } - } - public static void speak() { - if (configuration().root instanceof Quietable) { - ((Quietable)configuration().root).speak(); - } - } - - public static class ClassUseMapperPass extends Pass { - protected boolean cond() { - return cs.classuse; - } - protected void gen() throws DocletAbortException { - ClassUseMapper.generate(root, std.classtree); - } - public String title() { return "class use mapper"; } - } - - public static class TreeWriterPass extends Pass { - protected boolean cond() { - return cs.createtree; - } - protected void gen() throws DocletAbortException { - TreeWriter.generate(std.classtree); - } - public String title() { return "tree writer"; } - } - - public static class SplitIndexWriterPass extends Pass { - protected boolean cond() { - return cs.createindex && cs.splitindex; - } - protected void gen() throws DocletAbortException { - SplitIndexWriter.generate(std.indexBuilder(root, false)); - } - public String title() { return "split index"; } - } - - public static class SingleIndexWriterPass extends Pass { - protected boolean cond() { - return cs.createindex && !cs.splitindex; - } - protected void gen() throws DocletAbortException { - SingleIndexWriter.generate(std.indexBuilder(root, false)); - } - public String title() { return "single index"; } - } - - public static class DeprecatedListWriterPass extends Pass { - protected boolean cond() { - return !cs.nodeprecatedlist && !cs.nodeprecated; - } - protected void gen() throws DocletAbortException { - DeprecatedListWriter.generate(root); - } - public String title() { return "deprecated list"; } - } - - public static class AllClassesFrameWriterPass extends Pass { - protected void gen() throws DocletAbortException { - AllClassesFrameWriter.generate(std.indexBuilder(root, true)); - } - public String title() { return "all classes frame"; } - } - - public static class FrameOutputWriterPass extends Pass { - protected void gen() throws DocletAbortException { - FrameOutputWriter.generate(); - } - public String title() { return "output frame"; } - } - - public static class PackagesFileWriterPass extends Pass { - protected void gen() throws DocletAbortException { - PackagesFileWriter.generate(); - } - public String title() { return "packages files"; } - } - - public static class PackageIndexWriterPass extends Pass { - protected boolean cond(ConfigurationStandard cs) { - return cs.createoverview; - } - protected void gen() throws DocletAbortException { - PackageIndexWriter.generate(root); - } - public String title() { return "package index"; } - } - - public static class PackageIndexFrameWriterPass extends Pass { - protected boolean cond() { - return cs.packages.length > 1; - } - protected void gen() throws DocletAbortException { - PackageIndexFrameWriter.generate(); - } - public String title() { return "package index frame"; } - } - - protected Class[] preGenerationClasses() { - return new Class[] { - ClassUseMapperPass.class, - TreeWriterPass.class, - SplitIndexWriterPass.class, - SingleIndexWriterPass.class, - DeprecatedListWriterPass.class, - AllClassesFrameWriterPass.class, - FrameOutputWriterPass.class, - PackagesFileWriterPass.class, - PackageIndexWriterPass.class, - PackageIndexFrameWriterPass.class, - }; - } - - public static class SerializedFormWriterPass extends Pass { - protected void gen() throws DocletAbortException { - SerializedFormWriter.generate(root); - } - public String title() { return "serialized form"; } - } - - public static class PackageListWriterPass extends Pass { - protected void gen() throws DocletAbortException { - PackageListWriter.generate(root); - } - public String title() { return "package list"; } - } - - public static class HelpWriterPass extends Pass { - protected boolean cond() { - return cs.helpfile.length() == 0 && - !cs.nohelp; - } - protected void gen() throws DocletAbortException { - HelpWriter.generate(); - } - public String title() { return "help"; } - } - - public static class StylesheetWriterPass extends Pass { - protected boolean cond() { - return cs.stylesheetfile.length() == 0; - } - protected void gen() throws DocletAbortException { - StylesheetWriter.generate(); - } - public String title() { return "style sheet"; } - } - - - protected Class[] postGenerationClasses() { - return new Class[] { - SerializedFormWriterPass.class, - PackageListWriterPass.class, - HelpWriterPass.class, - StylesheetWriterPass.class, - }; - } - - public static class NoPublicClassesToDocumentCheck extends Check { - protected boolean cond() { - return root.classes().length == 0; - } - protected String message() { - return "doclet.No_Public_Classes_To_Document"; - } - } - public static class NoNonDeprecatedClassToDocumentCheck extends Check { - protected boolean cond() { - return cs.topFile.length() == 0; - } - protected String message() { - return "doclet.No_Non_Deprecated_Classes_To_Document"; - } - } - - protected Class[] checkClasses() { - return new Class[] { - NoPublicClassesToDocumentCheck.class, - NoNonDeprecatedClassToDocumentCheck.class, - }; - } -} - - diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/Statics.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/Statics.java deleted file mode 100644 index 55bcc8052..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/Statics.java +++ /dev/null @@ -1,253 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.doclets.standard; - -import org.aspectj.ajdoc.AdviceDoc; -import org.aspectj.ajdoc.AspectDoc; - -import com.sun.javadoc.ClassDoc; -import com.sun.javadoc.ProgramElementDoc; -import com.sun.tools.doclets.Util; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - -/** - * A splattering of misc. functionality. - * - * @author Jeff Palm - */ -public class Statics { - - /** - * Returns a aspectj-world type String of cd. - * - * @return either aspect interface or class depending - * on the type of cd. - */ - public static String type(ClassDoc cd) { - return cd instanceof AspectDoc - ? "aspect" : cd.isInterface() - ? "interface" : "class"; - } - - /** - * Returns the link target for member. - * - * @param member the ProgramElementDoc in question. - * @return the link target for member. - */ - public static String where(ProgramElementDoc member) { - return member.name(); - } - - /** - * Returns the link label for member. - * - * @param member the ProgramElementDoc in question. - * @return the link label for member. - */ - public static String label(ProgramElementDoc member) { - return member.name(); - } - - /** - * Returns the link target for member from - * cd. - * - * @param cd the class from which we're linking. - * @param member the ProgramElementDoc in question. - * @return the link target for member. - */ - public static String where(ClassDoc cd, ProgramElementDoc member) { - if (member instanceof AdviceDoc) { - return name(cd, (AdviceDoc)member).replace(' ','_').replace('#','-'); - } - return member.name(); - } - - /** - * Returns the link label for member from - * cd. - * - * @param cd the class from which we're linking. - * @param member the ProgramElementDoc in question. - * @return the link target for member. - */ - public static String label(ClassDoc cd, ProgramElementDoc member) { - return name(cd, member); - } - - /** - * Returns the name for member from - * cd. This is here because we don't - * want really print the name of advice. - * - * @param cd the class from which we're printing. - * @param member the ProgramElementDoc in question. - * @return the name for member. - */ - public static String name(ClassDoc cd, ProgramElementDoc member) { - if (member instanceof AdviceDoc) { - return name(cd, (AdviceDoc)member); - } - return member.name(); - } - - /** - * Returns the String that should be printed for - * an advice's name. - * - * @param cd the ClassDoc from where we're printing. - * @param advice the member in question. - * @return correct printing name for advice. - */ - public static String name(ClassDoc cd, AdviceDoc advice) { - String name = advice.name(); - int num = 1; - for (Iterator i = advice(cd).iterator(); i.hasNext();) { - AdviceDoc ad = (AdviceDoc)i.next(); - if (ad.equals(advice)) { - break; - } - if (ad.name().equals(name)) { - num++; - } - } - return name + " #" + num; - } - - /** - * Returns the advice contained in classdoc. - * - * @param cd ClassDoc in question. - * @return a List with the {@link AdviceDoc}s - * contained in cd. - */ - public static List advice(ClassDoc classdoc) { - if (!(classdoc instanceof AspectDoc)) return Collections.EMPTY_LIST; - AdviceDoc[] advice = ((AspectDoc)classdoc).advice(); - return advice == null ? Collections.EMPTY_LIST : Util.asList(advice); - } - - /** - * Returns an array of classes only. - * - * @param arr source array from where the ClassDocs in - * the result will come. - * @return an array of ClassDoc containing only - * classes, no aspects. - */ - public static ClassDoc[] classes(ClassDoc[] arr) { - List list = new ArrayList(); - for (int i = 0; i < arr.length; i++) { - if (!(arr[i] instanceof AspectDoc)) { - list.add(arr[i]); - } - } - return (ClassDoc[])list.toArray(new ClassDoc[list.size()]); - } - - /** - * Returns a list of the classes found in the - * passed in list of types. - * - * @param types List of ClassDocs. - * @return a List containing those ClassDocs in - * types that are not aspects. - * @see #types(List,boolean) - */ - public static List classes(List types) { - return types(types, false); - } - - /** - * Returns a list of the classes found in the - * passed in list of types. - * - * @param types List of ClassDocs. - * @return a List containing those ClassDocs in - * types that are aspects. - * @see #types(List,boolean) - */ - public static List aspects(List types) { - return types(types, true); - } - - /** - * Returns a list of ClassDocs taken from types - * that are aspects iff wantAspects. - * - * @param types source List of ClassDocs. - * @param wantAspects ClassDocs cin the resulting List will - * conform to the test: - * c instanceof AspectDoc) == wantAspects. - * @return a List of ClassDocs all who conform to the test: - * c instanceof AspectDoc) == wantAspects. - */ - public static List types(List types, boolean wantAspects) { - List list = new ArrayList(); - for (Iterator i = types.iterator(); i.hasNext();) { - ClassDoc cd = (ClassDoc)i.next(); - if ((cd instanceof AspectDoc) == wantAspects) { - list.add(cd); - } - } - return list; - } - - /** - * Returns a prequalified class link to cd using - * the link target where. - * - * @param writer base writer to use. - * @param cd class to where we're linking. - * @param where link target. - * @return prequalified class link using - * cd and where. - */ - public static String getPreQualifiedClassLink - (com.sun.tools.doclets.standard.SubWriterHolderWriter writer, - ClassDoc cd, - String where) { - return writer.getPkgName(cd) + writer.getClassLink(cd, where, cd.name()); - } - - /** - * Returns a prequalified class link to cd using - * the link target where returned by - * calling getPreQualifiedClassLink. - * - * @param writer base writer to use. - * @param cd class to where we're linking. - * @param where link target. - * @see #getPreQualifiedClassLink - */ - public static void printPreQualifiedClassLink - (com.sun.tools.doclets.standard.SubWriterHolderWriter writer, - ClassDoc cd, - String where) { - writer.print(getPreQualifiedClassLink(writer, cd, where)); - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/SubWriterHolderWriter.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/SubWriterHolderWriter.java deleted file mode 100644 index 7325844a4..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/SubWriterHolderWriter.java +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.doclets.standard; - -import com.sun.javadoc.ClassDoc; -import com.sun.javadoc.ProgramElementDoc; -import com.sun.tools.doclets.DocletAbortException; - -import java.io.IOException; - -public abstract class SubWriterHolderWriter - extends com.sun.tools.doclets.standard.SubWriterHolderWriter -{ - - public SubWriterHolderWriter(String filename) throws IOException { - super(filename); - } - - - public SubWriterHolderWriter(String path, String filename, String relpath) - throws IOException, DocletAbortException { - super(path, filename, relpath); - } - - public void printSummaryMember(AbstractSubWriter mw, ClassDoc cd, - ProgramElementDoc member) { - super.printSummaryMember(mw, cd, member); - if (mw instanceof AbstractSubWriterAJ) { - AbstractSubWriterAJ aj = (AbstractSubWriterAJ)mw; - if (aj.hasCrosscuts(cd, member)) { - aj.printSummaryCrosscuts(cd, member); - } - } - } - - public String getPreQualifiedClassLink(ClassDoc cd, String where) { - return getPkgName(cd) + getClassLink(cd, where, cd.name()); - } - - public void printPreQualifiedClassLink(ClassDoc cd, String where) { - print(getPreQualifiedClassLink(cd, where)); - } -} - - - - diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/SuperIntroductionSubWriter.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/SuperIntroductionSubWriter.java deleted file mode 100644 index ade3dcc6f..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/SuperIntroductionSubWriter.java +++ /dev/null @@ -1,181 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.doclets.standard; - -import org.aspectj.ajdoc.AspectDoc; -import org.aspectj.ajdoc.IntroducedSuperDoc; -import org.aspectj.ajdoc.IntroductionDoc; - -import com.sun.javadoc.ClassDoc; -import com.sun.javadoc.ProgramElementDoc; -import com.sun.javadoc.Type; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -public class SuperIntroductionSubWriter extends AbstractSubWriter { - - protected Class delegateClass() { - return null; //XXX ???? - } - - public SuperIntroductionSubWriter - (com.sun.tools.doclets.standard.SubWriterHolderWriter writer, - AspectDoc ad) - { - super(writer, ad); - } - - public SuperIntroductionSubWriter - (com.sun.tools.doclets.standard.SubWriterHolderWriter writer) - { - super(writer); - } - - protected final String keyName() { return "Super_Introduction"; } - - public void printInheritedSummaryAnchor(ClassDoc cd) {} - public void printInheritedSummaryLabel(ClassDoc cd) {} - protected void printInheritedSummaryLink(ClassDoc cd, ProgramElementDoc ped) {} - - protected void printSummaryLink(ClassDoc cd, ProgramElementDoc member) { - IntroducedSuperDoc intro = (IntroducedSuperDoc)member; - writer.codeEnd(); - writer.printText("doclet.declare_parents"); - print(' '); - Type[] targets = intro.targets(); - for (int i = 0; i < targets.length; i++) { - if (i > 0) print(", "); - printTypeLink(targets[i]); - } - print(' '); - String str = intro.isImplements() ? "implements" : "extends"; - writer.printClassLink(cd, link(intro), str, false); - print(' '); - Type[] types = intro.types(); - for (int i = 0; i < types.length; i++) { - if (i > 0) print(", "); - printTypeLink(types[i]); - } - - } - - protected static String link(IntroducedSuperDoc intro) { - String str = intro.isImplements() ? "+implements" : "+extends"; - Type[] types = intro.types(); - str += "%"; - for (int i = 0; i < types.length; i++) str += types[i].qualifiedTypeName(); - str += "%"; - ClassDoc[] targets = intro.targets(); - for (int i = 0; i < targets.length; i++) str += targets[i].qualifiedTypeName(); - return str; - } - - protected void printSummaryType(ProgramElementDoc member) {} - - protected void printBodyHtmlEnd(ClassDoc cd) {} - - protected void nonfinalPrintMember(ProgramElementDoc member) { - IntroducedSuperDoc intro = (IntroducedSuperDoc)member; - writer.anchor(link(intro)); - String head = intro.isImplements() ? "+implements " : "+extends "; - Type[] types = intro.types(); - for (int i = 0; i < types.length; i++) { - head += (i > 0 ? ", " : "") + types[i].typeName(); - } - printHead(head); - printFullComment(intro); - } - - protected void printDeprecatedLink(ProgramElementDoc member) { - //TODO: ??? - } - - protected List getMembers(ClassDoc cd) { - if (!(cd instanceof AspectDoc)) return Collections.EMPTY_LIST; - IntroductionDoc[] introductions = ((AspectDoc)cd).introductions(); - List list = new ArrayList(); - if (introductions == null) return list; - for (int i = 0; i < introductions.length; i++) { - IntroductionDoc intro = introductions[i]; - if (intro instanceof IntroducedSuperDoc) { - list.add(intro); - } - } - return list; - } - - public void printCrosscuts(ClassDoc cd, ProgramElementDoc member) { - org.aspectj.ajdoc.IntroducedSuperDoc intro = - (org.aspectj.ajdoc.IntroducedSuperDoc)member; - ClassDoc[] targets = intro.targets(); - if (targets.length > 0) { - writer.dt(); - writer.boldText("doclet.Introduced_on"); - writer.dd(); - writer.code(); - Set targetSet = new HashSet(); - for (int i = 0; i < targets.length; i++) { - targetSet.add(targets[i]); - } - List targetList = new ArrayList(targetSet); - Collections.sort(targetList); - for (Iterator i = targetList.iterator(); i.hasNext();) { - ClassDoc target = (ClassDoc)i.next(); - writer.printClassLink(target); - if (i.hasNext()) writer.print(", "); - - } - writer.codeEnd(); - } - } - - public void printSummaryCrosscuts(ClassDoc cd, - ProgramElementDoc member) { - Set set = new HashSet(); - org.aspectj.ajdoc.IntroducedSuperDoc intro = - (org.aspectj.ajdoc.IntroducedSuperDoc)member; - ClassDoc[] targets = intro.targets(); - for (int i = 0; i < targets.length; i++) { - set.add(targets[i]); - } - if (targets.length > 0) { - writer.boldText("doclet.Advises"); - List list = new ArrayList(set); - Collections.sort(list); - for (Iterator i = list.iterator(); i.hasNext();) { - print(' '); - ClassDoc target = (ClassDoc)i.next(); - writer.printClassLink(target); - if (i.hasNext()) print(","); - } - } - } - - public boolean hasCrosscuts(ClassDoc cd, ProgramElementDoc member) { - return true; - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/TreeWriter.java b/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/TreeWriter.java deleted file mode 100644 index 4119176bf..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/TreeWriter.java +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the debugger and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - */ -package org.aspectj.tools.doclets.standard; - -import com.sun.javadoc.ClassDoc; -import com.sun.tools.doclets.ClassTree; -import com.sun.tools.doclets.DocletAbortException; - -import java.io.IOException; -import java.util.List; - -public class TreeWriter - extends com.sun.tools.doclets.standard.TreeWriter -{ - protected class Del extends AbstractTreeWriter { - public Del(String s, ClassTree c) - throws IOException, DocletAbortException { - super(s, c); - } - public void print(String s) { - TreeWriter.this.print(s); - } - } - final protected Del del; - { - Standard.quiet(); - Del d = null; - try { - d = new Del(filename, classtree); - } catch (Exception e) { - Standard.configuration().standardmessage. - error("doclet.exception_encountered", - e+"", filename); - } finally { - del = d; - Standard.speak(); - } - } - protected void generateLevelInfo(ClassDoc parent, List list) { - del.generateLevelInfo(parent, list); - } - protected void generateTree(List list, String heading) { - del.generateTree(list, heading); - } - - public TreeWriter(String filename, ClassTree classtree) - throws IOException, DocletAbortException { - super(filename, classtree); - } - - public static void generate(ClassTree classtree) - throws DocletAbortException { - TreeWriter tw = null; - String filename = "overview-tree.html"; - try { - (tw = new TreeWriter(filename, classtree)). - generateTreeFile(); - } catch (IOException e) { - Standard.configuration().standardmessage. - error("doclet.exception_encountered", - e+"", filename); - throw new DocletAbortException(); - } finally { - if (tw != null) tw.close(); - } - } -} diff --git a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/resources/standard.properties b/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/resources/standard.properties deleted file mode 100644 index cc0021e82..000000000 --- a/aspectj-attic/ajdoc-src/org/aspectj/tools/doclets/standard/resources/standard.properties +++ /dev/null @@ -1,344 +0,0 @@ -# -doclet.exception_encountered= {0} encountered \n\ -\twhile attempting to create file: {1} -doclet.perform_copy_exception_encountered= {0} encountered while \n\ -performing copy. -doclet.exception={0} encountered \n\ -\twhile {1}. -doclet.Contents=Contents -doclet.Overview=Overview -doclet.Window_Overview={0}: Overview -doclet.Package=Package -doclet.Window_Package={0}: Package {1} -doclet.Window_ClassFile_label={0}: {1} -doclet.Window_Packages_title={0} -doclet.All_Packages=All Packages -doclet.Tree=Tree -doclet.Class_Hierarchy=Class Hierarchy -doclet.Class_Aspect_Hierarchy=Class/Aspect Hierarchy -doclet.Window_Class_Hierarchy={0}: Class/Aspect Hierarchy -doclet.Window_Package_Class_Hierarchy={0}: {1} Class Hierarchy -doclet.Interface_Hierarchy=Interface Hierarchy -doclet.Aspect_Hierarchy=Aspect Hierarchy -doclet.Prev=PREV -doclet.Next=NEXT -doclet.Prev_Class=PREV CLASS -doclet.Next_Class=NEXT CLASS -doclet.Prev_Package=PREV PACKAGE -doclet.Next_Package=NEXT PACKAGE -doclet.Prev_Letter=PREV LETTER -doclet.Next_Letter=NEXT LETTER -doclet.Show_Lists=SHOW LISTS -doclet.Hide_Lists=HIDE LISTS -doclet.Summary=SUMMARY: -doclet.Detail=DETAIL: -doclet.navInner=INNER -doclet.navField=FIELD -doclet.navField_Introduction=DECLARE FIELD -doclet.navSuper_Introduction=DECLARE PARENTS -doclet.navPointcut=POINTCUT -doclet.navConstructor=CONSTRUCTOR -doclet.navConstructor_Introduction=DECLARE CONSTRUCTOR -doclet.navMethod=METHOD -doclet.navMethod_Introduction=DECLARE METHOD -doclet.navAdvice=ADVICE -doclet.Index=Index -doclet.Window_Single_Index={0}: Index -doclet.Window_Split_Index={0}: {1}-Index -doclet.Help=Help -doclet.Interface=Interface -doclet.Class=Class -doclet.Aspect=Aspect -doclet.interface=interface -doclet.aspect=aspect -doclet.class=class -doclet.error=error -doclet.exception=exception -doclet.extends=extends -doclet.dominates=dominates -doclet.Package_private=(package private) -doclet.implements=implements -doclet.Since=Since: -doclet.Version=Version: -doclet.Author=Author: -doclet.See_Also=See Also: -doclet.introduced_by_parens=(declared in {0}) -doclet.by_parens= ({0} by {1}) -doclet.introduced_by=-- declared in {0} -doclet.Introduced_on=Declared for: -doclet.Introduced_from=Declared in: -doclet.See=See: -doclet.File_not_found=File not found: {0} -doclet.Package_Summary=Package Summary -doclet.Interface_Summary=Interface Summary -doclet.Exception_Summary=Exception Summary -doclet.Error_Summary=Error Summary -doclet.Class_Summary=Class Summary -doclet.Aspect_Summary=Aspect Summary -doclet.Inner_Class_Summary=Inner Class/Aspect Summary -doclet.Field_Summary=Field Summary -doclet.Field_Introduction_Summary=Summary of Fields Declared on Target Types -doclet.Super_Introduction_Summary=Summary of Parent Types Declared on Target Types -doclet.Pointcut_Summary=Pointcut Summary -doclet.Constructor_Summary=Constructor Summary -doclet.Constructor_Introduction_Summary=Summary of Constructors Declared on Target Types -doclet.Method_Summary=Method Summary -doclet.Method_Introduction_Summary=Summary of Methods Declared on Target Types -doclet.Advice_Summary=Advice Summary -doclet.Option_conflict=Option {0} conflicts with {1} -doclet.Option_reuse=Option reused: {0} -doclet.MissingSerialTag=in class {0}, missing @serial tag for default serializable field: {1}. -doclet.MissingSerialDataTag=in class {0}, missing @serialData tag in method {1}. -doclet.Interfaces=Interfaces -doclet.Exceptions=Exceptions -doclet.Errors=Errors -doclet.Classes=Classes -doclet.Aspects=Aspects -doclet.Packages=Packages -doclet.All_Classes=All Classes/Aspects -doclet.All_Superinterfaces=All Superinterfaces: -doclet.All_Implemented_Interfaces=All Implemented Interfaces: -doclet.Members=Members -doclet.None=None -doclet.CLASSES=CLASSES -doclet.MEMBERS=MEMBERS -doclet.NONE=NONE -doclet.Inner_Classes_Inherited_From_Class=Inner classes/aspects inherited from class {0} -doclet.Inner_Classes_Inherited_From=Inner classes/aspects inherited from {0} {1} -doclet.Methods_Inherited_From_Class=Methods inherited from class {0} -doclet.Methods_Inherited_From_Interface=Methods inherited from interface {0} -doclet.Methods_Inherited_From=Methods inherited from {0} {1} -doclet.Methods_Introduced_From=Methods declared in {0} {1} -doclet.Constructors_Introduced_From=Constructors declared in {0} {1} -doclet.Advice_Inherited_From_Aspect=Advice inherited from aspect {0} -doclet.Advice_Inherited_From=Advice inherited from {0} {1} -doclet.Fields_Inherited_From_Class=Fields inherited from class {0} -doclet.Fields_Inherited_From_Interface=Fields inherited from interface {0} -doclet.Fields_Inherited_From=Fields inherited from {0} {1} -doclet.Fields_Introduced_From=Fields declared in {0} {1} -doclet.Pointcuts_Inherited_From_Class=Pointcuts inherited from class {0} -doclet.Pointcuts_Inherited_From_Interface=Pointcuts inherited from interface {0} -doclet.Pointcuts_Inherited_From=Pointcuts inherited from {0} {1} -doclet.Serializable=Serializable -doclet.Externalizable=Externalizable -doclet.Class_0_implements_serializable=Class {0} implements Serializable -doclet.Serialized_Form=Serialized Form -doclet.Serialized_Form_methods=Serialization Methods -doclet.Serialized_Form_fields=Serialized Fields -doclet.Serialized_Form_class=Serialization Overview -doclet.Serializable_no_customization=No readObject or writeObject method declared. -doclet.Super_Introduction_Detail=Parent Types Declared on Target Types -doclet.Field_Detail=Field Detail -doclet.Field_Introduction_Detail=Fields Declared on Target Types -doclet.Pointcut_Detail=Pointcut Detail -doclet.Method_Detail=Method Detail -doclet.Method_Introduction_Detail=Methods Declared on Target Types -doclet.Advice_Detail=Advice Detail -doclet.Constructor_Detail=Constructor Detail -doclet.Constructor_Introduction_Detail=Constructors Declared on Target Types -doclet.Deprecated=Deprecated. -doclet.Deprecated_class=This class is deprecated. -doclet.navDeprecated=Deprecated -doclet.Deprecated_List=Deprecated List -doclet.Window_Deprecated_List={0}: Deprecated List -doclet.Note_0_is_deprecated=Note: {0} is deprecated. -doclet.Crosscuts=Affects: -doclet.Crosscut_by=Affected by: -doclet.Advised_by=Affected by: -doclet.Advises=Affects: -doclet.Parameters=Parameters: -doclet.Returns=Returns: -doclet.SerialData=Serial Data: -doclet.Throws=Throws: -doclet.Overrides=Overrides: -doclet.in_class={0} in class {1} -doclet.Generating_0=Generating {0}... -doclet.0_Fields_and_Methods="{0}" Fields and Methods -doclet.Index_of_Fields_and_Methods=Index of Fields and Methods -doclet.Static_variable_in=Static variable in {0} -doclet.Variable_in=Variable in {0} -doclet.Constructor_for=Constructor for {0} -doclet.Advice_in=Advice in {0} -doclet.Pointcut_in=Pointcut in {0} -doclet.Static_method_in=Static method in {0} -doclet.Method_in=Method in {0} -doclet.throws=throws -doclet.package=package -doclet.destination_directory_not_found_0=destination directory not found: {0} -doclet.MalformedURL=Malformed URL: {0} -doclet.File_error=Error reading file: {0} -doclet.URL_error=Error fetching URL: {0} -doclet.Method_Summary=Method Summary -doclet.No_Package_Comment_File=For Package {0} Package.Comment file not found -doclet.No_Source_For_Class=Source information for class {0} not available. -doclet.see.class_or_package_not_found=Tag {0}: Class or Package not found: {1} -doclet.see.malformed_tag=Tag {0}: Malformed: {1} -doclet.Inherited_API_Summary=Inherited API Summary -doclet.Deprecated_API=Deprecated API -doclet.Deprecated_Classes=Deprecated Classes -doclet.Deprecated_Interfaces=Deprecated Interfaces -doclet.Deprecated_Exceptions=Deprecated Exceptions -doclet.Deprecated_Errors=Deprecated Errors -doclet.Deprecated_Fields=Deprecated Fields -doclet.Deprecated_Constructors=Deprecated Constructors -doclet.Deprecated_Advices=Deprecated Advice -doclet.Deprecated_Pointcuts=Deprecated Pointcuts -doclet.Deprecated_Field_Introductions=Deprecated Fields Declared on Target Types -doclet.Deprecated_Method_Introductions=Deprecated Methods Declared on Target Types -doclet.Deprecated_Constructor_Introductions=Deprecated Constructors Declared on Target Types -doclet.Deprecated_Super_Introductions=Deprecated Parent Types Declared on Target Types -doclet.Deprecated_Methods=Deprecated Methods -doclet.Frame_Output=Frame Output -doclet.Docs_generated_by_Javadoc=Documentation generated by Javadoc. -doclet.Generated_Docs_Untitled=Generated Documentation (Untitled) -doclet.Blank=Blank -doclet.Other_Packages=Other Packages -doclet.Package_Description=Package {0} Description -doclet.Description=Description -doclet.Specified_By=Specified by: -doclet.in_interface={0} in interface {1} -doclet.Subclasses=Direct Known Subclasses or Subaspects: -doclet.Subinterfaces=All Known Subinterfaces: -doclet.Implementing_Classes=All Known Implementing Classes: -doclet.also=also -doclet.Option=Option -doclet.Or=Or -doclet.Frames=Frames -doclet.FRAMES=FRAMES -doclet.NO_FRAMES=NO FRAMES -doclet.Package_Hierarchies=Package Hierarchies: -doclet.Hierarchy_For_Package=Hierarchy For Package {0} -doclet.Source_Code=Source Code: -doclet.Help=Help -doclet.Hierarchy_For_All_Packages=Hierarchy For All Packages -doclet.Cannot_handle_no_packages=Cannot handle no packages. -doclet.Frame_Alert=Frame Alert -doclet.Overview-Member-Frame=Overview Member Frame -doclet.Frame_Warning_Message=This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. -doclet.Non_Frame_Version=Non-frame version. -doclet.Frame_Version=Frame version -doclet.Link_To=Link to -doclet.Following_From_Class=Following copied from class: {0} -doclet.Following_From_Interface=Following copied from interface: {0} -doclet.Description_From_Interface=Description copied from interface: {0} -doclet.Description_From_Class=Description copied from class: {0} -doclet.Copying_File_0_To_Dir_1=Copying file {0} to directory {1}... -doclet.Copying_File_0_To_File_1=Copying file {0} to file {1}... -doclet.Standard_doclet_invoked=Standard doclet invoked... -doclet.No_Public_Classes_To_Document=No public or protected classes found to document. -doclet.No_Non_Deprecated_Classes_To_Document=No non-deprecated classes found to document. -doclet.Interfaces_Italic=Interfaces (italic) -doclet.Enclosing_Class=Enclosing class: -doclet.All_Advisors:Known Advisors: -doclet.All_Advisees:Known Advisees: -doclet.Enclosing_=Enclosing {0}: -doclet.Help_title=API Help -doclet.Window_Help_title={0}: API Help -doclet.Help_line_1=How This API Document Is Organized -doclet.Help_line_2=This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows. -doclet.Help_line_3=The {0} page is the front page of this API document and provides a list of all packages with a summary for each. This page can also contain an overall description of the set of packages. -doclet.Help_line_4=Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain five categories: -doclet.Help_line_5=Class/Aspect/Interface -doclet.Help_line_6=Each class, aspect, interface, inner class, inner aspect, and inner interface has its own separate page. Each of these pages has three sections consisting of a class/aspect/interface description, summary tables, and detailed member descriptions: -doclet.Help_line_7=Class/aspect inheritance diagram -doclet.Help_line_8=Direct Subclasses/Subaspects -doclet.Help_line_9=All Known Subinterfaces -doclet.Help_line_10=All Known Implementing Classes/Aspects -doclet.Help_line_11=Class/aspect/interface declaration -doclet.Help_line_12=Class/aspect/interface description -doclet.Help_line_13=Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer. -doclet.Help_line_14=Use -doclet.Help_line_15=Each documented package, class and interface has its own Use page. This page describes what packages, classes, methods, constructors and fields use any part of the given class or package. Given a class or interface A, its Use page includes subclasses of A, fields declared as A, methods that return A, and methods and constructors with parameters of type A. You can access this page by first going to the package, class or interface, then clicking on the "Use" link in the navigation bar. -doclet.Help_line_16=Tree (Class/Aspect Hierarchy) -doclet.Help_line_17_with_tree_link=There is a {0} page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object. -doclet.Help_line_18=When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages. -doclet.Help_line_19=When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package. -doclet.Help_line_20_with_deprecated_api_link=The {0} page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations. -doclet.Help_line_21=Index -doclet.Help_line_22=The {0} contains an alphabetic list of all classes, interfaces, constructors, methods, and fields. -doclet.Help_line_23=Prev/Next -doclet.Help_line_24=These links take you to the next or previous class, interface, package, or related page. -doclet.Help_line_25=Frames/No Frames -doclet.Help_line_26=These links show and hide the HTML frames. All pages are available with or without frames. -doclet.Help_line_27=Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description. -doclet.Help_line_28=This help file applies to API documentation generated using the standard doclet. -doclet.The=The -doclet.Style_line_1=Javadoc style sheet -doclet.Style_line_2=Define colors, fonts and other style attributes here to override the defaults -doclet.Style_line_3=Page background color -doclet.Style_line_4=Table colors -doclet.Style_line_5=Dark mauve -doclet.Style_line_6=Light mauve -doclet.Style_line_7=White -doclet.Style_line_8=Font used in left-hand frame lists -doclet.Style_line_9=Example of smaller, sans-serif font in frames -doclet.Style_line_10=Navigation bar fonts and colors -doclet.Style_line_11=Dark Blue -doclet.ClassUse_Packages.that.use.0=Packages that use {0} -doclet.ClassUse_Uses.of.0.in.1=Uses of {0} in {1} -doclet.ClassUse_Classes.in.0.used.by.1=Classes in {0} used by {1} -doclet.ClassUse_Aspects.in.0.used.by.1=Aspects in {0} used by {1} -doclet.ClassUse_Subclass=Subclasses or subaspects of {0} in {1} -doclet.ClassUse_Subinterface=Subinterfaces of {0} in {1} -doclet.ClassUse_ImplementingClass=Classes in {1} that implement {0} -doclet.ClassUse_Field=Fields in {1} declared as {0} - -doclet.ClassUse_AdviceReturn=Advice in {1} that return {0} -doclet.ClassUse_AdviceArgs=Advice in {1} with parameters of type {0} -doclet.ClassUse_PointcutReturn=Pointcuts in {1} that return {0} -doclet.ClassUse_PointcutArgs=Pointcuts in {1} with parameters of type {0} -doclet.ClassUse_FieldIntroductions={0} fields declared by aspects in {1} -doclet.ClassUse_ClassIntroductions={0} parent class declarations by aspects in {1} -doclet.ClassUse_InterfaceIntroductions={0} parent interface declarations by aspects in {1} -doclet.ClassUse_ClassAdvisors=Aspects in {1} that affect {0} -doclet.ClassUse_AspectDominatees=Aspects in {1} that are dominated by {0} -doclet.ClassUse_AspectDominators=Aspects in {1} that dominate {0} - -doclet.ClassUse_MethodReturn=Methods in {1} that return {0} -doclet.ClassUse_MethodArgs=Methods in {1} with parameters of type {0} -doclet.ClassUse_MethodThrows=Methods in {1} that throw {0} -doclet.ClassUse_ConstructorArgs=Constructors in {1} with parameters of type {0} -doclet.ClassUse_ConstructorThrows=Constructors in {1} that throw {0} -doclet.ClassUse_No.usage.of.0=No usage of {0} -doclet.Window_ClassUse_Header={0}: Uses of {1} {2} -doclet.ClassUse_Title=Uses of {0}
{1} -doclet.navClassUse=Use -doclet.link_option_twice=Extern URL link option(link or linkoffline) used twice. -doclet.Error_in_packagelist=Error in using -group option: {0} {1} -doclet.Groupname_already_used=In -group option, groupname already used: {0} -doclet.Same_package_name_used=Package name format used twice: {0} -doclet.Packages_File_line_1=The front page has been relocated. -doclet.Packages_File_line_2=Please see: -doclet.usage=Provided by Standard doclet:\n\ - -d Destination directory for output files\n\ - -use Create class and package usage pages\n\ - -version Include @version paragraphs\n\ - -author Include @author paragraphs\n\ - -splitindex Split index into one file per letter\n\ - -windowtitle Browser window title for the documenation\n\ - -doctitle Include title for the package index(first) page\n\ - -header Include header text for each page\n\ - -footer Include footer text for each page\n\ - -bottom Include bottom text for each page\n\ - -link Create links to javadoc output at \n\ - -linkoffline Link to docs at using package list at \n\ - -group :.. Group specified packages together in overview page\n\ - -nodeprecated Do not include @deprecated information\n\ - -nosince Do not include @since information\n\ - -nodeprecatedlist Do not generate deprecated list\n\ - -notree Do not generate class hierarchy\n\ - -noindex Do not generate index\n\ - -nohelp Do not generate help link\n\ - -nonavbar Do not generate navigation bar\n\ - -serialwarn Generate warning about @serial tag\n\ - -charset Charset for cross-platform viewing of generated documentation.\n\ - -helpfile Include file that help link links to\n\ - -stylesheetfile File to change style of the generated documentation\n\ - -docencoding Output encoding name -doclet.xusage=Special options:\n\ - -Xnodate Do not include generation date in output -doclet.pass_msg=[ {0} started ] -doclet.done_msg=[ {0} done in {1} ms ] -doclet.starting_internal_compile=Starting internal compile... -doclet.initializing_world=Initializing world... -doclet.declare_parents=declare parents: diff --git a/aspectj-attic/ajdoc-testsrc/AjdocModuleTests.java b/aspectj-attic/ajdoc-testsrc/AjdocModuleTests.java deleted file mode 100644 index 5105931e1..000000000 --- a/aspectj-attic/ajdoc-testsrc/AjdocModuleTests.java +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the compiler and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - * - * Contributor(s): - */ - -// default package - -import junit.framework.*; - -public class AjdocModuleTests extends TestCase { - - public static Test suite() { - TestSuite suite = new TestSuite(AjdocModuleTests.class.getName()); - suite.addTest(org.aspectj.tools.ajdoc.AjdocTests.suite()); - return suite; - } - - public AjdocModuleTests(String name) { super(name); } - -} diff --git a/aspectj-attic/ajdoc-testsrc/org/aspectj/tools/ajdoc/AjdocTests.java b/aspectj-attic/ajdoc-testsrc/org/aspectj/tools/ajdoc/AjdocTests.java deleted file mode 100644 index 6da9a0f61..000000000 --- a/aspectj-attic/ajdoc-testsrc/org/aspectj/tools/ajdoc/AjdocTests.java +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This file is part of the compiler and core tools for the AspectJ(tm) - * programming language; see http://aspectj.org - * - * The contents of this file are subject to the Mozilla Public License - * Version 1.1 (the "License"); you may not use this file except in - * compliance with the License. You may obtain a copy of the License at - * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/. - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is AspectJ. - * - * The Initial Developer of the Original Code is Xerox Corporation. Portions - * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation. - * All Rights Reserved. - * - * Contributor(s): - */ - -package org.aspectj.tools.ajdoc; - -import junit.framework.*; - -public class AjdocTests extends TestCase { - - public static Test suite() { - TestSuite suite = new TestSuite(AjdocTests.class.getName()); - //$JUnit-BEGIN$ - suite.addTestSuite(SeeTagImplTest.class); - //$JUnit-END$ - return suite; - } - - public AjdocTests(String name) { super(name); } - -} diff --git a/aspectj-attic/ajdoc-testsrc/org/aspectj/tools/ajdoc/JUnitDriver.java b/aspectj-attic/ajdoc-testsrc/org/aspectj/tools/ajdoc/JUnitDriver.java deleted file mode 100644 index a25029d5f..000000000 --- a/aspectj-attic/ajdoc-testsrc/org/aspectj/tools/ajdoc/JUnitDriver.java +++ /dev/null @@ -1,117 +0,0 @@ -package org.aspectj.tools.ajdoc; -import junit.framework.Test; -import junit.framework.Assert; -import junit.textui.TestRunner; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -import java.io.File; - -import org.aspectj.tools.ajdoc.Main; - -/** - * Test driver for ajdoc - * currently only has disabled test cases to invoke ajdoc - * but not verify results. - * @deprecated org.aspectj.testing.harness.AjdocScript - */ -public class JUnitDriver extends TestCase { - private static final String[] ME - = new String[] {"org.aspectj.tools.ajdoc.JUnitDriver"}; - static final String ajbase = "c:/home/wes/aj"; - static final String testbase = ajbase + "/aj-build-modules/tests/ajdoc/JUnitDriver"; - static final String srcbase = ajbase + "/aspectj/modules/ajdoc/testsrc"; - - private AjdocTestCase[] CASES; - - protected void setUp() { - assertTrue(null == CASES); - System.setProperty("seetag.debug", "on"); - CASES = new AjdocTestCase[] - { // both disabled as samples not checked in - // getLinkTestCase() - //, getJUnitTestCase() - }; - } - - AjdocTestCase getLinkTestCase() { - String outDir = testbase + "/link/api"; - - new File(outDir).mkdirs(); - return new AjdocTestCase("Link", new String[] - { - "-d", outDir - , "-private" - , "-sourcepath", srcbase - , "test" // doc test package only - }); - } - - AjdocTestCase getJUnitTestCase() { - String outDir = "c:/home/doc/junit/api"; - - new File(outDir).mkdir(); - return new AjdocTestCase("JUnit", new String[] - { - "-d", outDir - , "-private" - , "-sourcepath" - , "c:/home/doc/junit/src" - , "junitjunit.awtui" - , "junit.extensions" - , "junit.framework" - , "junit.runner" - , "junit.swingui" - , "junit.swingui.icons" - , "junit.textui" - , "junit.ui" - }); - } - - public static void main(String[] args) { - - TestRunner.main(ME); - } - - /** todo result logging? */ - public static void log(String s) { - System.err.println(""+s); - } - - /** load all KNOWN_TEST_CLASSES */ - public static Test suite() { - TestSuite result = new TestSuite(); - result.addTestSuite(JUnitDriver.class); - return result; - } - - //------------------ instance members - public JUnitDriver(String name) { super(name); } - - /** - * Run known test cases in CASES - */ - public void testAll() { - assertTrue(null != CASES); - for (int i = 0; i < CASES.length; i++) { - CASES[i].run(this); - } - - } - /** this just invokes AJDoc but does not verify results */ - static class AjdocTestCase { - private final String label; - public final String[] args; - public AjdocTestCase(String label, String[] args) { - this.label = (null == label ? "no label" : label); - this.args = (null == args? new String[] {"help"} : args); - } - public void run(Assert assert) { - int result = Main.execute(args); - assert.assertTrue("result: " + result,0 == result); - // now verify... - } - } - -} - diff --git a/aspectj-attic/ajdoc-testsrc/org/aspectj/tools/ajdoc/SeeTagImplTest.java b/aspectj-attic/ajdoc-testsrc/org/aspectj/tools/ajdoc/SeeTagImplTest.java deleted file mode 100644 index 4080a869f..000000000 --- a/aspectj-attic/ajdoc-testsrc/org/aspectj/tools/ajdoc/SeeTagImplTest.java +++ /dev/null @@ -1,493 +0,0 @@ -package org.aspectj.tools.ajdoc; - -import junit.framework.Test; -import junit.textui.TestRunner; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -import java.util.Locale; - -import com.sun.javadoc.Doc; - - -/** - */ -public class SeeTagImplTest extends TestCase { - /** - * Run this class as a JUnit test case in the textui - */ - public static void main(String[] args) { - TestRunner.main(new String[]{"org.aspectj.tools.ajdoc.SeeTagImplTest"}); - } - - /** set to true to trigger assertion failures - * on any output to error printer. - */ - static boolean FAIL_ON_PRINTERR = false; - - public static Test suite() { - TestSuite result = new TestSuite(); - result.addTestSuite(SeeTagImplTest.class); - return result; - } - // argh - our only dependency on the compiler module is here XXX - static ErrPrinter ERRPRINTER = new ErrPrinter("SeeTagImplTest") { - public void printError(String error) { - super.printError(error); - if (FAIL_ON_PRINTERR) - assertTrue(error, false); - } - }; - - - public SeeTagImplTest(String name) { super(name); } - - protected void setUp() { - try { - System.setProperty("seetag.debug","on"); - } catch (SecurityException e) {} // ignore - ok if property off - } - - static class SeeTestCase { - final String input; - final String type; - final String member; - final String parms; - final String label; - SeeTagImpl result; - - public SeeTestCase(String input, String type, String member, - String parms, String label) { - this.input = input; - this.type = type; - this.member = member; - this.parms = parms; - this.label = label; - } - - /** - * Run test. - * This implementation creates a SeeTagImpl to test - * (only) SeeTagImpl.resolve(). - */ - public void run() { - result = make(input); - verify("label", label, result.getLabel()); - verify("type", type, renderType(result.getPackageName(), result.getClassName())); - verify("memberName", renderMember(member, parms), result.getMemberName()); - } - - /** factory for SeeTag based on input normally passed to constructor */ - SeeTagImpl make(String text) { - Doc doc = null; - String name = "@link"; - Locale locale = Locale.getDefault(); - return new SeeTagImpl(doc, name,text,locale,ERRPRINTER); - } - - /** render for comment on error */ - String renderSeeTagImpl(SeeTagImpl input) { - if (null == input) return "(SeeTagImpl) null"; - String label = render(input.getLabel()); - return renderType(input.getPackageName(), input.getClassName()) - + "#" + input.getMemberName() - + (0 == label.length()? "" : " " + label); - } - - String renderType(String pack, String cl) { - cl = render(cl); - pack = render(pack); - return (0 == pack.length() ? "": pack + ".") + cl; - } - - String renderMember(String name, String parms) { - name = render(name); - parms = render(parms); - return (0 == parms.length() ? name : name + parms); - } - - /** render a null string as "" instead of "null" */ - String render(String str) { - return (null == str ? "" : str); - } - - /** treat empty String as null String */ - String normalize(String str) { - if ((null == str) || (str.length() == 0)) { - return null; - } else { - return str+""; - } - } - - /** - * assert actual with expected, - * including label and entire input in message asserted. - */ - void verify(String label, String expected, String actual) { - expected = normalize(expected); - actual = normalize(actual); - String output = renderSeeTagImpl(result); - String message = "\""+expected+"\".equals(\"" + actual + "\")" - + " // " + label - + " (\"" + input + "\" -> \"" + output + "\")"; - if (null == expected) { - assertTrue(message, null==actual); - } else { - assertTrue(message, expected.equals(actual)); - } - } - - } - // example of generated -// static SeeTestCase[] CASES = new SeeTestCase[] -// { new SeeTestCase("Foo#bar() bash", "Foo", "bar", "()", "bash") -// }; -// public void test1() { CASES[1].run(); } - - // test cases generated by genSeeTestCases.sh - static final SeeTestCase[] CASES = new SeeTestCase[] { null // first is null - , new SeeTestCase("#memberName ", "", "memberName", "", "") // 0 - , new SeeTestCase(" #memberName ", "", "memberName", "", "") - , new SeeTestCase("#memberName label", "", "memberName", "", "label") // 2 - , new SeeTestCase(" #memberName label ", "", "memberName", "", "label") - , new SeeTestCase("#memberName a label", "", "memberName", "", "a label") // 4 - , new SeeTestCase(" #memberName a label ", "", "memberName", "", "a label") - , new SeeTestCase("#memberName() ", "", "memberName", "()", "") // 6 - , new SeeTestCase(" #memberName () ", "", "memberName", "()", "") - , new SeeTestCase("#memberName() label", "", "memberName", "()", "label") // 8 - , new SeeTestCase(" #memberName () label ", "", "memberName", "()", "label") - , new SeeTestCase("#memberName() a label", "", "memberName", "()", "a label") // 10 - , new SeeTestCase(" #memberName () a label ", "", "memberName", "()", "a label") - , new SeeTestCase("#memberName(int) ", "", "memberName", "(int)", "") // 12 - , new SeeTestCase(" #memberName (int) ", "", "memberName", "(int)", "") - , new SeeTestCase("#memberName(int) label", "", "memberName", "(int)", "label") // 14 - , new SeeTestCase(" #memberName (int) label ", "", "memberName", "(int)", "label") - , new SeeTestCase("#memberName(int) a label", "", "memberName", "(int)", "a label") // 16 - , new SeeTestCase(" #memberName (int) a label ", "", "memberName", "(int)", "a label") - , new SeeTestCase("#memberName(int,String) ", "", "memberName", "(int,String)", "") // 18 - , new SeeTestCase(" #memberName (int,String) ", "", "memberName", "(int,String)", "") - , new SeeTestCase("#memberName(int,String) label", "", "memberName", "(int,String)", "label") // 20 - , new SeeTestCase(" #memberName (int,String) label ", "", "memberName", "(int,String)", "label") - , new SeeTestCase("#memberName(int,String) a label", "", "memberName", "(int,String)", "a label") // 22 - , new SeeTestCase(" #memberName (int,String) a label ", "", "memberName", "(int,String)", "a label") - , new SeeTestCase("#memberName( int , String[ ][ ] ) ", "", "memberName", "( int , String[ ][ ] )", "") // 24 - , new SeeTestCase(" #memberName ( int , String[ ][ ] ) ", "", "memberName", "( int , String[ ][ ] )", "") - , new SeeTestCase("#memberName( int , String[ ][ ] ) label", "", "memberName", "( int , String[ ][ ] )", "label") // 26 - , new SeeTestCase(" #memberName ( int , String[ ][ ] ) label ", "", "memberName", "( int , String[ ][ ] )", "label") - , new SeeTestCase("#memberName( int , String[ ][ ] ) a label", "", "memberName", "( int , String[ ][ ] )", "a label") // 28 - , new SeeTestCase(" #memberName ( int , String[ ][ ] ) a label ", "", "memberName", "( int , String[ ][ ] )", "a label") - , new SeeTestCase("#memberName( foo.Bar , com.sun.X ) ", "", "memberName", "( foo.Bar , com.sun.X )", "") // 30 - , new SeeTestCase(" #memberName ( foo.Bar , com.sun.X ) ", "", "memberName", "( foo.Bar , com.sun.X )", "") - , new SeeTestCase("#memberName( foo.Bar , com.sun.X ) label", "", "memberName", "( foo.Bar , com.sun.X )", "label") // 32 - , new SeeTestCase(" #memberName ( foo.Bar , com.sun.X ) label ", "", "memberName", "( foo.Bar , com.sun.X )", "label") - , new SeeTestCase("#memberName( foo.Bar , com.sun.X ) a label", "", "memberName", "( foo.Bar , com.sun.X )", "a label") // 34 - , new SeeTestCase(" #memberName ( foo.Bar , com.sun.X ) a label ", "", "memberName", "( foo.Bar , com.sun.X )", "a label") - , new SeeTestCase("#memberName(foo.Bar) ", "", "memberName", "(foo.Bar)", "") // 36 - , new SeeTestCase(" #memberName (foo.Bar) ", "", "memberName", "(foo.Bar)", "") - , new SeeTestCase("#memberName(foo.Bar) label", "", "memberName", "(foo.Bar)", "label") // 38 - , new SeeTestCase(" #memberName (foo.Bar) label ", "", "memberName", "(foo.Bar)", "label") - , new SeeTestCase("#memberName(foo.Bar) a label", "", "memberName", "(foo.Bar)", "a label") // 40 - , new SeeTestCase(" #memberName (foo.Bar) a label ", "", "memberName", "(foo.Bar)", "a label") - , new SeeTestCase("Type#memberName ", "Type", "memberName", "", "") // 42 - , new SeeTestCase(" Type#memberName ", "Type", "memberName", "", "") - , new SeeTestCase("Type#memberName label", "Type", "memberName", "", "label") // 44 - , new SeeTestCase(" Type#memberName label ", "Type", "memberName", "", "label") - , new SeeTestCase("Type#memberName a label", "Type", "memberName", "", "a label") // 46 - , new SeeTestCase(" Type#memberName a label ", "Type", "memberName", "", "a label") - , new SeeTestCase("Type#memberName() ", "Type", "memberName", "()", "") // 48 - , new SeeTestCase(" Type#memberName () ", "Type", "memberName", "()", "") - , new SeeTestCase("Type#memberName() label", "Type", "memberName", "()", "label") // 50 - , new SeeTestCase(" Type#memberName () label ", "Type", "memberName", "()", "label") - , new SeeTestCase("Type#memberName() a label", "Type", "memberName", "()", "a label") // 52 - , new SeeTestCase(" Type#memberName () a label ", "Type", "memberName", "()", "a label") - , new SeeTestCase("Type#memberName(int) ", "Type", "memberName", "(int)", "") // 54 - , new SeeTestCase(" Type#memberName (int) ", "Type", "memberName", "(int)", "") - , new SeeTestCase("Type#memberName(int) label", "Type", "memberName", "(int)", "label") // 56 - , new SeeTestCase(" Type#memberName (int) label ", "Type", "memberName", "(int)", "label") - , new SeeTestCase("Type#memberName(int) a label", "Type", "memberName", "(int)", "a label") // 58 - , new SeeTestCase(" Type#memberName (int) a label ", "Type", "memberName", "(int)", "a label") - , new SeeTestCase("Type#memberName(int,String) ", "Type", "memberName", "(int,String)", "") // 60 - , new SeeTestCase(" Type#memberName (int,String) ", "Type", "memberName", "(int,String)", "") - , new SeeTestCase("Type#memberName(int,String) label", "Type", "memberName", "(int,String)", "label") // 62 - , new SeeTestCase(" Type#memberName (int,String) label ", "Type", "memberName", "(int,String)", "label") - , new SeeTestCase("Type#memberName(int,String) a label", "Type", "memberName", "(int,String)", "a label") // 64 - , new SeeTestCase(" Type#memberName (int,String) a label ", "Type", "memberName", "(int,String)", "a label") - , new SeeTestCase("Type#memberName( int , String[ ][ ] ) ", "Type", "memberName", "( int , String[ ][ ] )", "") // 66 - , new SeeTestCase(" Type#memberName ( int , String[ ][ ] ) ", "Type", "memberName", "( int , String[ ][ ] )", "") - , new SeeTestCase("Type#memberName( int , String[ ][ ] ) label", "Type", "memberName", "( int , String[ ][ ] )", "label") // 68 - , new SeeTestCase(" Type#memberName ( int , String[ ][ ] ) label ", "Type", "memberName", "( int , String[ ][ ] )", "label") - , new SeeTestCase("Type#memberName( int , String[ ][ ] ) a label", "Type", "memberName", "( int , String[ ][ ] )", "a label") // 70 - , new SeeTestCase(" Type#memberName ( int , String[ ][ ] ) a label ", "Type", "memberName", "( int , String[ ][ ] )", "a label") - , new SeeTestCase("Type#memberName( foo.Bar , com.sun.X ) ", "Type", "memberName", "( foo.Bar , com.sun.X )", "") // 72 - , new SeeTestCase(" Type#memberName ( foo.Bar , com.sun.X ) ", "Type", "memberName", "( foo.Bar , com.sun.X )", "") - , new SeeTestCase("Type#memberName( foo.Bar , com.sun.X ) label", "Type", "memberName", "( foo.Bar , com.sun.X )", "label") // 74 - , new SeeTestCase(" Type#memberName ( foo.Bar , com.sun.X ) label ", "Type", "memberName", "( foo.Bar , com.sun.X )", "label") - , new SeeTestCase("Type#memberName( foo.Bar , com.sun.X ) a label", "Type", "memberName", "( foo.Bar , com.sun.X )", "a label") // 76 - , new SeeTestCase(" Type#memberName ( foo.Bar , com.sun.X ) a label ", "Type", "memberName", "( foo.Bar , com.sun.X )", "a label") - , new SeeTestCase("Type#memberName(foo.Bar) ", "Type", "memberName", "(foo.Bar)", "") // 78 - , new SeeTestCase(" Type#memberName (foo.Bar) ", "Type", "memberName", "(foo.Bar)", "") - , new SeeTestCase("Type#memberName(foo.Bar) label", "Type", "memberName", "(foo.Bar)", "label") // 80 - , new SeeTestCase(" Type#memberName (foo.Bar) label ", "Type", "memberName", "(foo.Bar)", "label") - , new SeeTestCase("Type#memberName(foo.Bar) a label", "Type", "memberName", "(foo.Bar)", "a label") // 82 - , new SeeTestCase(" Type#memberName (foo.Bar) a label ", "Type", "memberName", "(foo.Bar)", "a label") - , new SeeTestCase("junit.Type#memberName ", "junit.Type", "memberName", "", "") // 84 - , new SeeTestCase(" junit.Type#memberName ", "junit.Type", "memberName", "", "") - , new SeeTestCase("junit.Type#memberName label", "junit.Type", "memberName", "", "label") // 86 - , new SeeTestCase(" junit.Type#memberName label ", "junit.Type", "memberName", "", "label") - , new SeeTestCase("junit.Type#memberName a label", "junit.Type", "memberName", "", "a label") // 88 - , new SeeTestCase(" junit.Type#memberName a label ", "junit.Type", "memberName", "", "a label") - , new SeeTestCase("junit.Type#memberName() ", "junit.Type", "memberName", "()", "") // 90 - , new SeeTestCase(" junit.Type#memberName () ", "junit.Type", "memberName", "()", "") - , new SeeTestCase("junit.Type#memberName() label", "junit.Type", "memberName", "()", "label") // 92 - , new SeeTestCase(" junit.Type#memberName () label ", "junit.Type", "memberName", "()", "label") - , new SeeTestCase("junit.Type#memberName() a label", "junit.Type", "memberName", "()", "a label") // 94 - , new SeeTestCase(" junit.Type#memberName () a label ", "junit.Type", "memberName", "()", "a label") - , new SeeTestCase("junit.Type#memberName(int) ", "junit.Type", "memberName", "(int)", "") // 96 - , new SeeTestCase(" junit.Type#memberName (int) ", "junit.Type", "memberName", "(int)", "") - , new SeeTestCase("junit.Type#memberName(int) label", "junit.Type", "memberName", "(int)", "label") // 98 - , new SeeTestCase(" junit.Type#memberName (int) label ", "junit.Type", "memberName", "(int)", "label") - , new SeeTestCase("junit.Type#memberName(int) a label", "junit.Type", "memberName", "(int)", "a label") // 100 - , new SeeTestCase(" junit.Type#memberName (int) a label ", "junit.Type", "memberName", "(int)", "a label") - , new SeeTestCase("junit.Type#memberName(int,String) ", "junit.Type", "memberName", "(int,String)", "") // 102 - , new SeeTestCase(" junit.Type#memberName (int,String) ", "junit.Type", "memberName", "(int,String)", "") - , new SeeTestCase("junit.Type#memberName(int,String) label", "junit.Type", "memberName", "(int,String)", "label") // 104 - , new SeeTestCase(" junit.Type#memberName (int,String) label ", "junit.Type", "memberName", "(int,String)", "label") - , new SeeTestCase("junit.Type#memberName(int,String) a label", "junit.Type", "memberName", "(int,String)", "a label") // 106 - , new SeeTestCase(" junit.Type#memberName (int,String) a label ", "junit.Type", "memberName", "(int,String)", "a label") - , new SeeTestCase("junit.Type#memberName( int , String[ ][ ] ) ", "junit.Type", "memberName", "( int , String[ ][ ] )", "") // 108 - , new SeeTestCase(" junit.Type#memberName ( int , String[ ][ ] ) ", "junit.Type", "memberName", "( int , String[ ][ ] )", "") - , new SeeTestCase("junit.Type#memberName( int , String[ ][ ] ) label", "junit.Type", "memberName", "( int , String[ ][ ] )", "label") // 110 - , new SeeTestCase(" junit.Type#memberName ( int , String[ ][ ] ) label ", "junit.Type", "memberName", "( int , String[ ][ ] )", "label") - , new SeeTestCase("junit.Type#memberName( int , String[ ][ ] ) a label", "junit.Type", "memberName", "( int , String[ ][ ] )", "a label") // 112 - , new SeeTestCase(" junit.Type#memberName ( int , String[ ][ ] ) a label ", "junit.Type", "memberName", "( int , String[ ][ ] )", "a label") - , new SeeTestCase("junit.Type#memberName( foo.Bar , com.sun.X ) ", "junit.Type", "memberName", "( foo.Bar , com.sun.X )", "") // 114 - , new SeeTestCase(" junit.Type#memberName ( foo.Bar , com.sun.X ) ", "junit.Type", "memberName", "( foo.Bar , com.sun.X )", "") - , new SeeTestCase("junit.Type#memberName( foo.Bar , com.sun.X ) label", "junit.Type", "memberName", "( foo.Bar , com.sun.X )", "label") // 116 - , new SeeTestCase(" junit.Type#memberName ( foo.Bar , com.sun.X ) label ", "junit.Type", "memberName", "( foo.Bar , com.sun.X )", "label") - , new SeeTestCase("junit.Type#memberName( foo.Bar , com.sun.X ) a label", "junit.Type", "memberName", "( foo.Bar , com.sun.X )", "a label") // 118 - , new SeeTestCase(" junit.Type#memberName ( foo.Bar , com.sun.X ) a label ", "junit.Type", "memberName", "( foo.Bar , com.sun.X )", "a label") - , new SeeTestCase("junit.Type#memberName(foo.Bar) ", "junit.Type", "memberName", "(foo.Bar)", "") // 120 - , new SeeTestCase(" junit.Type#memberName (foo.Bar) ", "junit.Type", "memberName", "(foo.Bar)", "") - , new SeeTestCase("junit.Type#memberName(foo.Bar) label", "junit.Type", "memberName", "(foo.Bar)", "label") // 122 - , new SeeTestCase(" junit.Type#memberName (foo.Bar) label ", "junit.Type", "memberName", "(foo.Bar)", "label") - , new SeeTestCase("junit.Type#memberName(foo.Bar) a label", "junit.Type", "memberName", "(foo.Bar)", "a label") // 124 - , new SeeTestCase(" junit.Type#memberName (foo.Bar) a label ", "junit.Type", "memberName", "(foo.Bar)", "a label") - , new SeeTestCase("org.aspectj.Type#memberName ", "org.aspectj.Type", "memberName", "", "") // 126 - , new SeeTestCase(" org.aspectj.Type#memberName ", "org.aspectj.Type", "memberName", "", "") - , new SeeTestCase("org.aspectj.Type#memberName label", "org.aspectj.Type", "memberName", "", "label") // 128 - , new SeeTestCase(" org.aspectj.Type#memberName label ", "org.aspectj.Type", "memberName", "", "label") - , new SeeTestCase("org.aspectj.Type#memberName a label", "org.aspectj.Type", "memberName", "", "a label") // 130 - , new SeeTestCase(" org.aspectj.Type#memberName a label ", "org.aspectj.Type", "memberName", "", "a label") - , new SeeTestCase("org.aspectj.Type#memberName() ", "org.aspectj.Type", "memberName", "()", "") // 132 - , new SeeTestCase(" org.aspectj.Type#memberName () ", "org.aspectj.Type", "memberName", "()", "") - , new SeeTestCase("org.aspectj.Type#memberName() label", "org.aspectj.Type", "memberName", "()", "label") // 134 - , new SeeTestCase(" org.aspectj.Type#memberName () label ", "org.aspectj.Type", "memberName", "()", "label") - , new SeeTestCase("org.aspectj.Type#memberName() a label", "org.aspectj.Type", "memberName", "()", "a label") // 136 - , new SeeTestCase(" org.aspectj.Type#memberName () a label ", "org.aspectj.Type", "memberName", "()", "a label") - , new SeeTestCase("org.aspectj.Type#memberName(int) ", "org.aspectj.Type", "memberName", "(int)", "") // 138 - , new SeeTestCase(" org.aspectj.Type#memberName (int) ", "org.aspectj.Type", "memberName", "(int)", "") - , new SeeTestCase("org.aspectj.Type#memberName(int) label", "org.aspectj.Type", "memberName", "(int)", "label") // 140 - , new SeeTestCase(" org.aspectj.Type#memberName (int) label ", "org.aspectj.Type", "memberName", "(int)", "label") - , new SeeTestCase("org.aspectj.Type#memberName(int) a label", "org.aspectj.Type", "memberName", "(int)", "a label") // 142 - , new SeeTestCase(" org.aspectj.Type#memberName (int) a label ", "org.aspectj.Type", "memberName", "(int)", "a label") - , new SeeTestCase("org.aspectj.Type#memberName(int,String) ", "org.aspectj.Type", "memberName", "(int,String)", "") // 144 - , new SeeTestCase(" org.aspectj.Type#memberName (int,String) ", "org.aspectj.Type", "memberName", "(int,String)", "") - , new SeeTestCase("org.aspectj.Type#memberName(int,String) label", "org.aspectj.Type", "memberName", "(int,String)", "label") // 146 - , new SeeTestCase(" org.aspectj.Type#memberName (int,String) label ", "org.aspectj.Type", "memberName", "(int,String)", "label") - , new SeeTestCase("org.aspectj.Type#memberName(int,String) a label", "org.aspectj.Type", "memberName", "(int,String)", "a label") // 148 - , new SeeTestCase(" org.aspectj.Type#memberName (int,String) a label ", "org.aspectj.Type", "memberName", "(int,String)", "a label") - , new SeeTestCase("org.aspectj.Type#memberName( int , String[ ][ ] ) ", "org.aspectj.Type", "memberName", "( int , String[ ][ ] )", "") // 150 - , new SeeTestCase(" org.aspectj.Type#memberName ( int , String[ ][ ] ) ", "org.aspectj.Type", "memberName", "( int , String[ ][ ] )", "") - , new SeeTestCase("org.aspectj.Type#memberName( int , String[ ][ ] ) label", "org.aspectj.Type", "memberName", "( int , String[ ][ ] )", "label") // 152 - , new SeeTestCase(" org.aspectj.Type#memberName ( int , String[ ][ ] ) label ", "org.aspectj.Type", "memberName", "( int , String[ ][ ] )", "label") - , new SeeTestCase("org.aspectj.Type#memberName( int , String[ ][ ] ) a label", "org.aspectj.Type", "memberName", "( int , String[ ][ ] )", "a label") // 154 - , new SeeTestCase(" org.aspectj.Type#memberName ( int , String[ ][ ] ) a label ", "org.aspectj.Type", "memberName", "( int , String[ ][ ] )", "a label") - , new SeeTestCase("org.aspectj.Type#memberName( foo.Bar , com.sun.X ) ", "org.aspectj.Type", "memberName", "( foo.Bar , com.sun.X )", "") // 156 - , new SeeTestCase(" org.aspectj.Type#memberName ( foo.Bar , com.sun.X ) ", "org.aspectj.Type", "memberName", "( foo.Bar , com.sun.X )", "") - , new SeeTestCase("org.aspectj.Type#memberName( foo.Bar , com.sun.X ) label", "org.aspectj.Type", "memberName", "( foo.Bar , com.sun.X )", "label") // 158 - , new SeeTestCase(" org.aspectj.Type#memberName ( foo.Bar , com.sun.X ) label ", "org.aspectj.Type", "memberName", "( foo.Bar , com.sun.X )", "label") - , new SeeTestCase("org.aspectj.Type#memberName( foo.Bar , com.sun.X ) a label", "org.aspectj.Type", "memberName", "( foo.Bar , com.sun.X )", "a label") // 160 - , new SeeTestCase(" org.aspectj.Type#memberName ( foo.Bar , com.sun.X ) a label ", "org.aspectj.Type", "memberName", "( foo.Bar , com.sun.X )", "a label") - , new SeeTestCase("org.aspectj.Type#memberName(foo.Bar) ", "org.aspectj.Type", "memberName", "(foo.Bar)", "") // 162 - , new SeeTestCase(" org.aspectj.Type#memberName (foo.Bar) ", "org.aspectj.Type", "memberName", "(foo.Bar)", "") - , new SeeTestCase("org.aspectj.Type#memberName(foo.Bar) label", "org.aspectj.Type", "memberName", "(foo.Bar)", "label") // 164 - , new SeeTestCase(" org.aspectj.Type#memberName (foo.Bar) label ", "org.aspectj.Type", "memberName", "(foo.Bar)", "label") - , new SeeTestCase("org.aspectj.Type#memberName(foo.Bar) a label", "org.aspectj.Type", "memberName", "(foo.Bar)", "a label") // 166 - , new SeeTestCase(" org.aspectj.Type#memberName (foo.Bar) a label ", "org.aspectj.Type", "memberName", "(foo.Bar)", "a label") - }; - public void testLink1() { CASES[1].run(); } - public void testLink2() { CASES[2].run(); } - public void testLink3() { CASES[3].run(); } - public void testLink4() { CASES[4].run(); } - public void testLink5() { CASES[5].run(); } - public void testLink6() { CASES[6].run(); } - public void testLink7() { CASES[7].run(); } - public void testLink8() { CASES[8].run(); } - public void testLink9() { CASES[9].run(); } - public void testLink10() { CASES[10].run(); } - public void testLink11() { CASES[11].run(); } - public void testLink12() { CASES[12].run(); } - public void testLink13() { CASES[13].run(); } - public void testLink14() { CASES[14].run(); } - public void testLink15() { CASES[15].run(); } - public void testLink16() { CASES[16].run(); } - public void testLink17() { CASES[17].run(); } - public void testLink18() { CASES[18].run(); } - public void testLink19() { CASES[19].run(); } - public void testLink20() { CASES[20].run(); } - public void testLink21() { CASES[21].run(); } - public void testLink22() { CASES[22].run(); } - public void testLink23() { CASES[23].run(); } - public void testLink24() { CASES[24].run(); } - public void testLink25() { CASES[25].run(); } - public void testLink26() { CASES[26].run(); } - public void testLink27() { CASES[27].run(); } - public void testLink28() { CASES[28].run(); } - public void testLink29() { CASES[29].run(); } - public void testLink30() { CASES[30].run(); } - public void testLink31() { CASES[31].run(); } - public void testLink32() { CASES[32].run(); } - public void testLink33() { CASES[33].run(); } - public void testLink34() { CASES[34].run(); } - public void testLink35() { CASES[35].run(); } - public void testLink36() { CASES[36].run(); } - public void testLink37() { CASES[37].run(); } - public void testLink38() { CASES[38].run(); } - public void testLink39() { CASES[39].run(); } - public void testLink40() { CASES[40].run(); } - public void testLink41() { CASES[41].run(); } - public void testLink42() { CASES[42].run(); } - public void testLink43() { CASES[43].run(); } - public void testLink44() { CASES[44].run(); } - public void testLink45() { CASES[45].run(); } - public void testLink46() { CASES[46].run(); } - public void testLink47() { CASES[47].run(); } - public void testLink48() { CASES[48].run(); } - public void testLink49() { CASES[49].run(); } - public void testLink50() { CASES[50].run(); } - public void testLink51() { CASES[51].run(); } - public void testLink52() { CASES[52].run(); } - public void testLink53() { CASES[53].run(); } - public void testLink54() { CASES[54].run(); } - public void testLink55() { CASES[55].run(); } - public void testLink56() { CASES[56].run(); } - public void testLink57() { CASES[57].run(); } - public void testLink58() { CASES[58].run(); } - public void testLink59() { CASES[59].run(); } - public void testLink60() { CASES[60].run(); } - public void testLink61() { CASES[61].run(); } - public void testLink62() { CASES[62].run(); } - public void testLink63() { CASES[63].run(); } - public void testLink64() { CASES[64].run(); } - public void testLink65() { CASES[65].run(); } - public void testLink66() { CASES[66].run(); } - public void testLink67() { CASES[67].run(); } - public void testLink68() { CASES[68].run(); } - public void testLink69() { CASES[69].run(); } - public void testLink70() { CASES[70].run(); } - public void testLink71() { CASES[71].run(); } - public void testLink72() { CASES[72].run(); } - public void testLink73() { CASES[73].run(); } - public void testLink74() { CASES[74].run(); } - public void testLink75() { CASES[75].run(); } - public void testLink76() { CASES[76].run(); } - public void testLink77() { CASES[77].run(); } - public void testLink78() { CASES[78].run(); } - public void testLink79() { CASES[79].run(); } - public void testLink80() { CASES[80].run(); } - public void testLink81() { CASES[81].run(); } - public void testLink82() { CASES[82].run(); } - public void testLink83() { CASES[83].run(); } - public void testLink84() { CASES[84].run(); } - public void testLink85() { CASES[85].run(); } - public void testLink86() { CASES[86].run(); } - public void testLink87() { CASES[87].run(); } - public void testLink88() { CASES[88].run(); } - public void testLink89() { CASES[89].run(); } - public void testLink90() { CASES[90].run(); } - public void testLink91() { CASES[91].run(); } - public void testLink92() { CASES[92].run(); } - public void testLink93() { CASES[93].run(); } - public void testLink94() { CASES[94].run(); } - public void testLink95() { CASES[95].run(); } - public void testLink96() { CASES[96].run(); } - public void testLink97() { CASES[97].run(); } - public void testLink98() { CASES[98].run(); } - public void testLink99() { CASES[99].run(); } - public void testLink100() { CASES[100].run(); } - public void testLink101() { CASES[101].run(); } - public void testLink102() { CASES[102].run(); } - public void testLink103() { CASES[103].run(); } - public void testLink104() { CASES[104].run(); } - public void testLink105() { CASES[105].run(); } - public void testLink106() { CASES[106].run(); } - public void testLink107() { CASES[107].run(); } - public void testLink108() { CASES[108].run(); } - public void testLink109() { CASES[109].run(); } - public void testLink110() { CASES[110].run(); } - public void testLink111() { CASES[111].run(); } - public void testLink112() { CASES[112].run(); } - public void testLink113() { CASES[113].run(); } - public void testLink114() { CASES[114].run(); } - public void testLink115() { CASES[115].run(); } - public void testLink116() { CASES[116].run(); } - public void testLink117() { CASES[117].run(); } - public void testLink118() { CASES[118].run(); } - public void testLink119() { CASES[119].run(); } - public void testLink120() { CASES[120].run(); } - public void testLink121() { CASES[121].run(); } - public void testLink122() { CASES[122].run(); } - public void testLink123() { CASES[123].run(); } - public void testLink124() { CASES[124].run(); } - public void testLink125() { CASES[125].run(); } - public void testLink126() { CASES[126].run(); } - public void testLink127() { CASES[127].run(); } - public void testLink128() { CASES[128].run(); } - public void testLink129() { CASES[129].run(); } - public void testLink130() { CASES[130].run(); } - public void testLink131() { CASES[131].run(); } - public void testLink132() { CASES[132].run(); } - public void testLink133() { CASES[133].run(); } - public void testLink134() { CASES[134].run(); } - public void testLink135() { CASES[135].run(); } - public void testLink136() { CASES[136].run(); } - public void testLink137() { CASES[137].run(); } - public void testLink138() { CASES[138].run(); } - public void testLink139() { CASES[139].run(); } - public void testLink140() { CASES[140].run(); } - public void testLink141() { CASES[141].run(); } - public void testLink142() { CASES[142].run(); } - public void testLink143() { CASES[143].run(); } - public void testLink144() { CASES[144].run(); } - public void testLink145() { CASES[145].run(); } - public void testLink146() { CASES[146].run(); } - public void testLink147() { CASES[147].run(); } - public void testLink148() { CASES[148].run(); } - public void testLink149() { CASES[149].run(); } - public void testLink150() { CASES[150].run(); } - public void testLink151() { CASES[151].run(); } - public void testLink152() { CASES[152].run(); } - public void testLink153() { CASES[153].run(); } - public void testLink154() { CASES[154].run(); } - public void testLink155() { CASES[155].run(); } - public void testLink156() { CASES[156].run(); } - public void testLink157() { CASES[157].run(); } - public void testLink158() { CASES[158].run(); } - public void testLink159() { CASES[159].run(); } - public void testLink160() { CASES[160].run(); } - public void testLink161() { CASES[161].run(); } - public void testLink162() { CASES[162].run(); } - public void testLink163() { CASES[163].run(); } - public void testLink164() { CASES[164].run(); } - public void testLink165() { CASES[165].run(); } - public void testLink166() { CASES[166].run(); } - public void testLink167() { CASES[167].run(); } - public void testLink168() { CASES[168].run(); } - - // end of test cases generated - -} - - - diff --git a/aspectj-attic/ajdoc-testsrc/org/aspectj/tools/ajdoc/genSeeTestCases.sh b/aspectj-attic/ajdoc-testsrc/org/aspectj/tools/ajdoc/genSeeTestCases.sh deleted file mode 100644 index ab8e7587e..000000000 --- a/aspectj-attic/ajdoc-testsrc/org/aspectj/tools/ajdoc/genSeeTestCases.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -# generate test cases for {@link} tags - -## permitted variants: -# - everything but member name can be empty -# - spaces between everything except around sharp # -# - 0..n parm types -# - simple or qualified type names -# - Type[ ][ ] but not Type [ ] [ ] -# todo: -# - URL's acceptable for link?? - -count=0 -pre=" " -echo " static final SeeTestCase[] CASES = new SeeTestCase[] { null // first is null" - -for type in "" Type junit.Type org.aspectj.Type; do -for name in memberName; do -for parms in "" "()" "(int)" "(int,String)" "( int , String[ ][ ] )" "( foo.Bar , com.sun.X )" "(foo.Bar)" ; do -for label in "" label "a label"; do - - # method, field X no spaces, spaces - echo "$pre, new SeeTestCase(\"$type#$name$parms $label\", \"$type\", \"$name\", \"$parms\", \"$label\") // $count" - echo "$pre, new SeeTestCase(\" $type#$name $parms $label \", \"$type\", \"$name\", \"$parms\", \"$label\")" - count=`expr $count + 2` -done; done; done; done; -echo "${pre}};"; - -i=0 -while [ $i -lt $count ] ; do - i=`expr $i + 1` # first is null - echo " public void testLink$i() { CASES[$i].run(); }" -done - - diff --git a/aspectj-attic/readme-aspectj-attic-module.html b/aspectj-attic/readme-aspectj-attic-module.html deleted file mode 100644 index 3611c5b50..000000000 --- a/aspectj-attic/readme-aspectj-attic-module.html +++ /dev/null @@ -1,28 +0,0 @@ - -AspectJ attic - -

AspectJ attic

- -The AspectJ attic includes code that is unused now but might -be part of at least investigations for future solutions. -None of this code is used or distributed with AspectJ binaries. -Some of it depends on code under other licenses. That code is -not included here, so this project does not compile. - -Dependencies not specified in the .project file: -
    -
  • ajdoc depends on the J2SE 1.3 tools.jar. - Other versions will not work.
  • -
  • ajdoc depends on the AspectJ 1.0 compiler. - The 1.1 compiler will not work.
  • -
  • The testing file-comparison uses jdiff code, - available from the JEdit sourceforge project - (http://sourceforge.net/projects/jedit) under GPL. - (Not to be confused with the jdiff sourceforge - project, which produces API differences.) -
  • -
- -See also any development notes in the respective source directories. - - diff --git a/aspectj-attic/testing-src/AjcTaskTester.java b/aspectj-attic/testing-src/AjcTaskTester.java deleted file mode 100644 index 0f9e728ba..000000000 --- a/aspectj-attic/testing-src/AjcTaskTester.java +++ /dev/null @@ -1,219 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 1999-2001 Xerox Corporation, - * 2002 Palo Alto Research Center, Incorporated (PARC). - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Common Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * Xerox/PARC initial implementation - * ******************************************************************/ - - -import java.io.*; -import java.util.*; -import org.apache.tools.ant.*; -import org.apache.tools.ant.taskdefs.*; -import org.apache.tools.ant.types.*; - -/** - * Tests the AJC ant task. - */ -public class AjcTaskTester extends AntTaskTester { - - protected final static String TEST_CLASSES = "test-classes"; - protected final static String TEST_SOURCES = "../src"; - protected File buildDir = null; - - /** - * We use "tests/ant/etc/ajc.xml". - */ - public String getAntFile() { - return "tests/ant/etc/ajc.xml"; - } - - /** - * Put {@link #TEST_CLASSES} and {@link #TEST_SOURCES} - * into the user properties. - */ - protected Map getUserProperties() { - Map userProps = new HashMap(); - userProps.put("ant.test.classes", TEST_CLASSES); - userProps.put("ant.test.sources", TEST_SOURCES); - return userProps; - } - - ////// Begin tests ////////////////////////////////////////////// - - public void test1() { wantClasses("One"); } - public void test2() { wantClasses("One,Two"); } - public void test3() { wantClasses("One,Two,Three"); } - public void test4() { wantClasses("One"); } - public void test4b() { wantClasses("One"); } - public void test5() { wantClasses("One,Two"); } - public void test5b() { wantClasses("One,Two"); } - public void test6() { wantClasses("One,Two,Three"); } - public void test6b() { wantClasses("One,Two,Three"); } - public void test8() { wantClasses("One"); } - public void test9() { wantClasses("One"); } - public void test10() { wantClasses("One"); } - public void test11() { wantClasses("One"); } - public void test12() { wantClasses(""); } - public void test13() { wantClasses("One"); } - public void fail1(BuildException be) {} - public void fail2(BuildException be) {} - public void fail3(BuildException be) {} - - public void test1_fork() { wantClasses("One"); } - public void test2_fork() { wantClasses("One,Two"); } - public void test3_fork() { wantClasses("One,Two,Three"); } - public void test4_fork() { wantClasses("One"); } - public void test4b_fork() { wantClasses("One"); } - public void test5_fork() { wantClasses("One,Two"); } - public void test5b_fork() { wantClasses("One,Two"); } - public void test6_fork() { wantClasses("One,Two,Three"); } - public void test6b_fork() { wantClasses("One,Two,Three"); } - public void test8_fork() { wantClasses("One"); } - public void test9_fork() { wantClasses("One"); } - public void test10_fork() { wantClasses("One"); } - public void test11_fork() { wantClasses("One"); } - public void test12_fork() { wantClasses(""); } - public void test13_fork() { wantClasses("One"); } - public void fail1_fork(BuildException be) {} - public void fail2_fork(BuildException be) {} - public void fail3_fork(BuildException be) {} - - ////// End tests //////////////////////////////////////////////// - - /** - * Make the build dir -- e.g. call {@link #makeBuildDir} - */ - protected void beforeEveryTask() { - makeBuildDir(); - } - - /** - * Assert classes and clear build dir. - * - * @see #checkClasses() - * @see #clearBuildDir() - */ - protected void afterEveryTask() { - checkClasses(); - clearBuildDir(); - } - - /** - * Expect the classes found in - * classNamesWithoutExtensions - * - * @param classNamesWithoutExtensions Array of class names without - * extensions we want to see. - * @see #wantClasses(List) - */ - protected void wantClasses(String[] classNamesWithoutExtensions) { - List list = new Vector(); - for (int i = 0; i < classNamesWithoutExtensions.length; i++) { - list.add(classNamesWithoutExtensions[i]); - } - wantClasses(list); - } - - /** - * Expect the classes found in - * classNamesWithoutExtensions - * - * @param classNamesWithoutExtensions String of class names without - * extensions we want to see separated - * by , ,, or - * ;. - * @see #wantClasses(List) - */ - protected void wantClasses(String classNamesWithoutExtensions) { - StringTokenizer tok = new StringTokenizer(classNamesWithoutExtensions, " ,;"); - List list = new Vector(); - while (tok.hasMoreTokens()) { - list.add(tok.nextToken()); - } - wantClasses(list); - } - - /** - * Expected each class name found in - * classNamesWithoutExtensions. - * - * @param classNamesWithoutExtensions List of class names without - * exntensions. - * @see #want(Object) - */ - protected void wantClasses(List classNamesWithoutExtensions) { - Iterator iter = classNamesWithoutExtensions.iterator(); - while (iter.hasNext()) { - String className = iter.next() + ""; - className = className.replace('.', '/').replace('\\', '/'); - want(className + ".class"); - } - } - - /** - * Assert that all classes in {@link #wants} were found. - */ - protected void checkClasses() { - Iterator iter = wants.iterator(); - while (iter.hasNext()) { - String className = iter.next() + ""; - File file = new File(buildDir, className); - if (file != null && file.exists()) { - have(className); - } - } - } - - /** - * Create a new build dir. - */ - protected void init() { - buildDir = new File(project.getBaseDir(), TEST_CLASSES); - } - - /** - * Make a new build dir using ANT. - */ - protected void makeBuildDir() { - try { - Mkdir mkdir = (Mkdir)project.createTask("mkdir"); - mkdir.setDir(buildDir); - mkdir.execute(); - } catch (BuildException be) { - be.printStackTrace(); - } - } - - /** - * Clear the build dir using ANT. - */ - protected void clearBuildDir() { - try { - Delete delete = (Delete)project.createTask("delete"); - FileSet fileset = new FileSet(); - fileset.setDir(buildDir); - fileset.setIncludes("**"); - delete.addFileset(fileset); - delete.execute(); - } catch (BuildException be) { - be.printStackTrace(); - } - } - - /** - * Invoke {@link #runTests(String[])} on a - * new instanceof {@link #AjcTaskTester}. - * - * @param args Command line arguments. - */ - public static void main(String[] args) { - new AjcTaskTester().runTests(args); - } -} diff --git a/aspectj-attic/testing-src/AjcTaskTester2.java b/aspectj-attic/testing-src/AjcTaskTester2.java deleted file mode 100644 index f5c5b36db..000000000 --- a/aspectj-attic/testing-src/AjcTaskTester2.java +++ /dev/null @@ -1,202 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 1999-2001 Xerox Corporation, - * 2002 Palo Alto Research Center, Incorporated (PARC). - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Common Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * Xerox/PARC initial implementation - * ******************************************************************/ - - -import java.io.*; -import java.util.*; -import org.apache.tools.ant.*; -import org.apache.tools.ant.taskdefs.*; -import org.apache.tools.ant.types.*; - - -/** - * Tests the AJC2 ant task. - */ -public class AjcTaskTester2 extends AntTaskTester { - - protected final static String TEST_CLASSES = "test-classes"; - protected final static String TEST_SOURCES = "../src"; - protected File buildDir = null; - - /** - * We use "tests/ant/etc/ajc2.xml". - */ - public String getAntFile() { - return "tests/ant/etc/ajc2.xml"; - } - - /** - * Put {@link #TEST_CLASSES} and {@link #TEST_SOURCES} - * into the user properties. - */ - protected Map getUserProperties() { - Map userProps = new HashMap(); - userProps.put("ant.test.classes", TEST_CLASSES); - userProps.put("ant.test.sources", TEST_SOURCES); - return userProps; - } - - ////// Begin tests ////////////////////////////////////////////// - - public void test1() { wantClasses("One"); } - public void test2() { wantClasses("One,Two"); } - public void test3() { wantClasses("One,Two,Three"); } - public void test4() { wantClasses("One"); } - public void test4b() { wantClasses("One"); } - public void test5() { wantClasses("One,Two"); } - public void test5b() { wantClasses("One,Two"); } - public void test6() { wantClasses("One,Two,Three"); } - public void test6b() { wantClasses("One,Two,Three"); } - public void test8() { wantClasses("One"); } - public void test9() { wantClasses("One"); } - public void test10() { wantClasses("One"); } - public void test11() { wantClasses("One"); } - public void test12() { wantClasses(""); } - public void test13() { wantClasses("One"); } - public void fail1(BuildException be) {} - public void fail2(BuildException be) {} - public void fail3(BuildException be) {} - - ////// End tests //////////////////////////////////////////////// - - /** - * Make the build dir -- e.g. call {@link #makeBuildDir} - */ - protected void beforeEveryTask() { - makeBuildDir(); - } - - /** - * Assert classes and clear build dir. - * - * @see #checkClasses() - * @see #clearBuildDir() - */ - protected void afterEveryTask() { - checkClasses(); - clearBuildDir(); - } - - - /** - * Expect the classes found in - * classNamesWithoutExtensions - * - * @param classNamesWithoutExtensions Array of class names without - * extensions we want to see. - * @see #wantClasses(List) - */ - protected void wantClasses(String[] classNamesWithoutExtensions) { - List list = new Vector(); - for (int i = 0; i < classNamesWithoutExtensions.length; i++) { - list.add(classNamesWithoutExtensions[i]); - } - wantClasses(list); - } - - /** - * Expect the classes found in - * classNamesWithoutExtensions - * - * @param classNamesWithoutExtensions String of class names without - * extensions we want to see separated - * by , ,, or - * ;. - * @see #wantClasses(List) - */ - protected void wantClasses(String classNamesWithoutExtensions) { - StringTokenizer tok = new StringTokenizer(classNamesWithoutExtensions, ",;"); - List list = new Vector(); - while (tok.hasMoreTokens()) { - list.add(tok.nextToken()); - } - wantClasses(list); - } - - /** - * Expected each class name found in - * classNamesWithoutExtensions. - * - * @param classNamesWithoutExtensions List of class names without - * exntensions. - * @see #want(Object) - */ - protected void wantClasses(List classNamesWithoutExtensions) { - Iterator iter = classNamesWithoutExtensions.iterator(); - while (iter.hasNext()) { - String className = iter.next() + ""; - className = className.replace('.', '/').replace('\\', '/'); - want(className + ".class"); - } - } - - /** - * Assert that all classes in {@link #wants} were found. - */ - protected void checkClasses() { - Iterator iter = wants.iterator(); - while (iter.hasNext()) { - String className = iter.next() + ""; - File file = new File(buildDir, className); - if (file != null && file.exists()) { - have(className); - } - } - } - - /** - * Create a new build dir. - */ - protected void init() { - buildDir = new File(project.getBaseDir(), TEST_CLASSES); - } - - /** - * Make a new build dir using ANT. - */ - protected void makeBuildDir() { - try { - Mkdir mkdir = (Mkdir)project.createTask("mkdir"); - mkdir.setDir(buildDir); - mkdir.execute(); - } catch (BuildException be) { - be.printStackTrace(); - } - } - - /** - * Clear the build dir using ANT. - */ - protected void clearBuildDir() { - try { - Delete delete = (Delete)project.createTask("delete"); - FileSet fileset = new FileSet(); - fileset.setDir(buildDir); - fileset.setIncludes("**"); - delete.addFileset(fileset); - delete.execute(); - } catch (BuildException be) { - be.printStackTrace(); - } - } - - /** - * Invoke {@link #runTests(String[])} on a - * new instanceof {@link #AjcTaskTester2}. - * - * @param args Command line arguments. - */ - public static void main(String[] args) { - new AjcTaskTester2().runTests(args); - } -} diff --git a/aspectj-attic/testing-src/AjdocTaskTester.java b/aspectj-attic/testing-src/AjdocTaskTester.java deleted file mode 100644 index a0e397013..000000000 --- a/aspectj-attic/testing-src/AjdocTaskTester.java +++ /dev/null @@ -1,366 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 1999-2001 Xerox Corporation, - * 2002 Palo Alto Research Center, Incorporated (PARC). - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Common Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * Xerox/PARC initial implementation - * ******************************************************************/ - - -import java.io.*; -import java.util.*; -import org.apache.tools.ant.*; -import org.apache.tools.ant.taskdefs.*; -import org.apache.tools.ant.types.*; - -/** - * Tests the Ajdoc ant task. - */ -public class AjdocTaskTester extends AntTaskTester { - - /** todo correlate with basedir, local.properties in test-ant-task */ - protected final static String TEST_DOCDIR - = "test-docs"; - protected final static String TEST_SOURCES = "../src"; - protected File docDir = null; - - /** - * We use "tests/ant/etc/ajc.xml". - */ - public String getAntFile() { - return "tests/ant/etc/ajdoc.xml"; - } - - /** - * Put {@link #TEST_DOCDIR} and {@link #TEST_SOURCES} - * into the user properties. - */ - protected Map getUserProperties() { - Map userProps = new HashMap(); - // these are in local.properties per test-ant-tasks.xml - //userProps.put("ajdoc.relative.doc.dir", TEST_DOCDIR ); - //userProps.put("ajdoc.relative.src.dir", TEST_SOURCES); - return userProps; - } - - ////// Begin tests ////////////////////////////////////////////// - - public void test_stylesheetfile() { - avoid(STYLESHEET_CSS); - wantFiles("One.html"); - wantFiles("mystylesheet.css"); - } - - public void test_helpfile() { - avoid(HELP_DOC_HTML); - wantFiles("One.html"); - wantFiles("myhelp.html"); - } - - public void test_nodeprecatedlist_no() { - wantFiles("One.html"); - } - public void test_nodeprecatedlist_yes() { - avoid(DEPRECATED_LIST_HTML); - wantFiles("One.html"); - } - - public void test_nodeprecated_no() { wantFiles("One.html"); } - public void test_nodeprecated_yes() { wantFiles("One.html"); } - - public void test_use_no() { - wantFiles("One.html"); - } - public void test_use_yes() { - wantFiles("One.html"); - wantFiles("class-use/One.html"); - } - - public void test_standard_no() { - wantFiles("One.html"); - } - public void test_standard_yes() { - wantFiles("One.html"); - } - - public void test_author_no() { wantFiles("One.html"); } - public void test_author_yes() { wantFiles("One.html"); } - - public void test_public_no() { wantFiles("One.html"); } - public void test_public_yes() { wantFiles("One.html"); } - public void test_package_no() { wantFiles("One.html"); } - public void test_package_yes() { wantFiles("One.html"); } - public void test_protected_no() { wantFiles("One.html"); } - public void test_protected_yes() { wantFiles("One.html"); } - public void test_private_no() { wantFiles("One.html"); } - public void test_private_yes() { wantFiles("One.html"); } - - public void test_splitindex_no() { - wantFiles("One.html"); - } - public void test_splitindex_yes() { - avoid(INDEX_ALL_HTML); - wantFiles("One.html"); - } - - public void test_windowtitle() { - wantFiles("One.html"); - } - public void test_doctitle() { - wantFiles("One.html"); - } - public void test_bottom() { - wantFiles("One.html"); - } - public void test_footer() { - wantFiles("One.html"); - } - public void test_header() { - wantFiles("One.html"); - } - - public void test_nohelp_no() { - wantFiles("One.html"); - } - public void test_nohelp_yes() { - avoid(HELP_DOC_HTML); - wantFiles("One.html"); - } - - public void test_noindex_no() { - wantFiles("One.html"); - } - public void test_noindex_yes() { - avoid(INDEX_ALL_HTML); - wantFiles("One.html"); - } - - public void test_notree_no() { - wantFiles("One.html"); - } - public void test_notree_yes() { - avoid(OVERVIEW_TREE_HTML); - wantFiles("One.html"); - } - - public void test985() { - wantFiles("p1/One.html,p1/pp1/One.html"); - wantFiles("p2/Two.html,p2/pp2/Two.html"); - } - public void test986() { - wantFiles("p1/One.html,p1/pp1/One.html"); - } - public void test987() { - wantFiles("p1/One.html"); - wantFiles("p2/Two.html"); - } - public void test988() { - wantFiles("p1/One.html"); - } - public void test989() { - wantFiles("p1/One.html,p1/pp1/One.html"); - wantFiles("p2/Two.html,p2/pp2/Two.html"); - } - public void test990() { - wantFiles("p1/One.html,p1/pp1/One.html"); - wantFiles("p2/Two.html,p2/pp2/Two.html"); - } - public void test991() { - wantFiles("p1/One.html,p1/pp1/One.html"); - wantFiles("p2/Two.html"); - } - public void test992() { - wantFiles("p1/One.html,p2/Two.html"); - } - public void test993() { - wantFiles("p1/One.html,p1/pp1/One.html"); - } - public void test994() { - wantFiles("p1/One.html,p1/pp1/One.html"); - } - public void test995() { - wantFiles("p1/One.html"); - } - public void test996() { - wantFiles("One.html,Two.html"); - } - public void test997() { - wantFiles("One.html"); - } - public void test998() { - wantFiles("One.html,Two.html"); - } - public void test999() { - wantFiles("One.html"); - } - - - - ////// End tests //////////////////////////////////////////////// - - private final static int OVERVIEW_TREE_HTML = 0x000001; - private final static int INDEX_ALL_HTML = 0x000002; - private final static int DEPRECATED_LIST_HTML = 0x000004; - private final static int ALLCLASSES_FRAME_HTML = 0x000008; - private final static int INDEX_HTML = 0x000010; - private final static int PACKAGES_HTML = 0x000020; - private final static int OVERVIEW_SUMMARY_HTML = 0x000040; - private final static int PACKAGE_LIST = 0x000080; - private final static int HELP_DOC_HTML = 0x000100; - private final static int STYLESHEET_CSS = 0x000200; - private final static int ALL = 0x0003ff; - private final static int TOP = ((ALL<<1)|1)&~ALL; - private final static String[] FILES = new String[] { - "overview-tree.html", - "index-all.html", - "deprecated-list.html", - "allclasses-frame.html", - "index.html", - "packages.html", - "overview-summary.html", - "package-list", - "help-doc.html", - "stylesheet.css", - }; - - private void wantFiles(int mods) { - mods &= (ALL | TOP); - - for (int c = 0; mods != 0x1; c++, mods >>= 0x1) { - if ((mods & 0x1) == 0x1) { - wantFiles(FILES[c]); - } else { - avoidFiles(FILES[c]); - } - } - } - - private int MODS = ALL; - private void avoid(int mods) { - MODS &= ~mods; - } - - /** - * Make the doc dir -- e.g. call {@link #makeDocDir} - */ - protected void beforeEveryTask() { - makeDocDir(); - wantFiles(MODS); - } - - /** - * Assert classes and clear doc dir. - * - * @see #checkDocs() - * @see #clearDocDir() - */ - protected void afterEveryTask() { - checkDocs(); - clearDocDir(); - MODS = ALL; - } - - protected void avoidFiles(String filesWithoutHtmlExtensions) { - List list = new ArrayList(); - for (StringTokenizer tok = - new StringTokenizer(filesWithoutHtmlExtensions, " ,;"); - tok.hasMoreTokens();) { - list.add(tok.nextToken()); - } - avoidFiles(list); - } - - protected void avoidFiles(List filesWithoutHtmlExtensions) { - for (Iterator iter = filesWithoutHtmlExtensions.iterator(); iter.hasNext();) { - dont(iter.next()+""); - } - } - - protected void wantFiles(String filesWithoutHtmlExtensions) { - List list = new ArrayList(); - for (StringTokenizer tok = - new StringTokenizer(filesWithoutHtmlExtensions, " ,;"); - tok.hasMoreTokens();) { - list.add(tok.nextToken()); - } - wantFiles(list); - } - - protected void wantFiles(List filesWithoutHtmlExtensions) { - for (Iterator iter = filesWithoutHtmlExtensions.iterator(); iter.hasNext();) { - want(iter.next()+""); - } - } - - protected void checkDocs() { - for (Iterator iter = wants.iterator(); iter.hasNext();) { - String filename = iter.next() + ""; - File file = new File(docDir, filename); - if (file != null && file.exists()) { - have(filename); - } else { - //System.err.println("westodo expected " + file.getPath()); - } - } - for (Iterator iter = donts.iterator(); iter.hasNext();) { - String filename = iter.next() + ""; - File file = new File(docDir, filename); - if (file != null && file.exists()) { - have(filename); - } else { - //System.err.println("westodo avoiding " + file.getPath()); - } - } - } - - /** - * Create a new doc dir. - */ - protected void init() { - docDir = new File(project.getBaseDir(), TEST_DOCDIR); - } - - /** - * Make a new doc dir using ANT. - */ - protected void makeDocDir() { - try { - Mkdir mkdir = (Mkdir)project.createTask("mkdir"); - mkdir.setDir(docDir); - mkdir.execute(); - } catch (BuildException be) { - be.printStackTrace(); - } - } - - /** - * Clear the build dir using ANT. - */ - protected void clearDocDir() { - try { - Delete delete = (Delete)project.createTask("delete"); - FileSet fileset = new FileSet(); - fileset.setDir(docDir); - fileset.setIncludes("**"); - delete.addFileset(fileset); - delete.execute(); - } catch (BuildException be) { - be.printStackTrace(); - } - } - - /** - * Invoke {@link #runTests(String[])} on a - * new instanceof {@link #AjdocTaskTester}. - * - * @param args Command line arguments. - */ - public static void main(String[] args) { - new AjdocTaskTester().runTests(args); - } -} diff --git a/aspectj-attic/testing-src/AntTaskTester.java b/aspectj-attic/testing-src/AntTaskTester.java deleted file mode 100644 index 1f032e74f..000000000 --- a/aspectj-attic/testing-src/AntTaskTester.java +++ /dev/null @@ -1,409 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 1999-2001 Xerox Corporation, - * 2002 Palo Alto Research Center, Incorporated (PARC). - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Common Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * Xerox/PARC initial implementation - * ******************************************************************/ - - -import org.apache.tools.ant.*; -import java.io.*; -import java.lang.reflect.*; -import java.util.*; - -/** - * Provides utility methods to test ant tasks. - */ -public abstract class AntTaskTester implements BuildListener { - - public abstract String getAntFile(); - - protected PrintStream out = System.out; - protected PrintStream err = System.err; - protected void info(Object msg) { - out.println(" [" + msg + "]"); - } - - protected Project project; - protected String taskname = "unset"; - - protected List errors = new Vector(); - protected void throwable(Throwable t) { - error(taskname, t); - t.printStackTrace(); - } - protected void error(String task, Object msg) { - error("[" + task + "]: " + msg); - } - protected void error(Object msg) { - err.println("Error: " + msg); - errors.add(msg); - } - - protected List wants = new Vector(); - protected void want(Object object) { - wants.add(object); - } - protected List haves = new Vector(); - protected void have(Object object) { - haves.add(object); - } - protected List donts = new Vector(); - protected void dont(Object object) { - donts.add(object); - } - - protected void clear() { - wants = new Vector(); - haves = new Vector(); - donts = new Vector(); - } - - protected final boolean verbose = verbose(); - protected boolean verbose() { return false; } - protected void log(String msg) { - if (verbose) out.println("[ " + msg + " ]"); - } - - public void printSummary() { - Iterator iter = errors.iterator(); - out.println(); - out.println("----------------------- Test Summary -----------------------"); - if (errors.size() == 0) { - out.println("no errors"); - } else { - out.println(errors.size() + " error" + (errors.size() > 1 ? "s" : "")); - while (iter.hasNext()) { - out.println(" " + iter.next()); - } - } - out.println("------------------------------------------------------------"); - } - - /** - * Checks the all the assertions we wanted were achieved - * and all those received were desired. - */ - protected void checkAfterTask() { - log("checking after task"); - for (Iterator i = wants.iterator(); i.hasNext();) { - Object want = i.next(); - check(haves.contains(want), - "didn't see " + want + " in " + haves); - } - for (Iterator i = haves.iterator(); i.hasNext();) { - Object have = i.next(); - check(wants.contains(have), - "shouldn't have seen " + have + " in " + wants); - } - for (Iterator i = donts.iterator(); i.hasNext();) { - Object dont = i.next(); - check(!haves.contains(dont), - "should't have seen " + dont + " in " + haves); - } - } - - /** - * Logs an error in !b with message msg. - * - * @param b true for an error. - * @param msg Failure message. - */ - protected void check(boolean b, String msg) { - if (!b) error(taskname, msg); - } - - /** - * Calls {@link #check(boolean,String)} with the result - * of comparing equality of o1 and o2, - * failing with message msg. - * - * @param o1 First comparison. - * @param o2 Other comparison. - * @param msg Failure message. - */ - protected void check(Object o1, Object o2, String msg) { - if (o1 != null) { - check(o1.equals(o2), msg); - } else if (o2 != null) { - check(o2.equals(o1), msg); - } else { - check(true, msg); - } - } - - /** - * Calls {@link #runProject} with args and - * the result of {@link #getAntFile}. - * - * @param args Arguments given on the command line. - * @see #runProject(String[], String) - */ - public void runTests(String[] args) { - runProject(args, getAntFile()); - } - - /** - * Loads the project, collects a list of methods, and - * passes these methods to {@link #runProject(Method[])}. - * - * @param args Command line arguments. - * @param buildFile XML file that we are giving to ANT. - * @see #runProject(Method[]) - */ - public void runProject(String[] args, String buildFile) { - loadProject(buildFile); - Method[] methods = null; - if (args == null || args.length == 0 || args[0].equals("${args}")) { - methods = getClass().getMethods(); - } else { - methods = new Method[args.length]; - for (int i = 0; i < args.length; i++) { - String name = args[i]; - if (!Character.isJavaIdentifierStart(name.charAt(0)) || // todo wes: was (i)? - name.charAt(0) == '$') { - continue; - } - try { - methods[i] = getClass().getMethod(name, new Class[]{}); - } catch (NoSuchMethodException nsme) { - methods[i] = null; - } - } - } - runProject(methods); - } - - /** - * Execute the targets whose name matches those found in methods. - * - * @param methods List of methods to execute. - */ - protected final void runProject(Method[] methods) { - if (methods == null || methods.length < 1) { - return; - } - for (int i = 0; i < methods.length; i++) { - Method method = methods[i]; - if (method == null) { - error("a method is null!"); - continue; - } - taskname = method.getName(); - if (taskname.startsWith("test")) { - info("test task: " + taskname); - try { - method.invoke(this, new Object[]{}); - beforeTasks(); - execute(taskname); - afterTasks(); - } catch (Throwable t) { - throwable(t); - } finally { - info("done task: " + taskname); - } - } else if (taskname.startsWith("fail")) { - info("fail task: " + taskname); - try { - beforeTasks(); - want(taskname + "-error"); - execute(taskname); - afterTasks(); - } catch (Throwable t) { - if (t instanceof BuildException) { - have(taskname + "-error"); - try { - method.invoke(this, new Object[]{t}); - } catch (Throwable tt) { - throwable(tt); - } - } else { - throwable(t); - } - } finally { - info("done task: " + taskname); - } - } - } - printSummary(); - } - - /** - * Called before every task. - */ - private final void beforeTasks() { - clear(); - beforeMethod(); - beforeEveryTask(); - } - - /** - * Called after every task. - */ - private final void afterTasks() { - afterMethod(); - afterEveryTask(); - checkAfterTask(); - } - - /** - * Invokes the method with prefix prefix. - * - * @param prefix Prefix of the method to execute. - */ - private final void taskMethod(String prefix) { - String name = prefix + Character.toUpperCase(taskname.charAt(0)) + - taskname.substring(1); - try { - Method method = getClass().getDeclaredMethod(name, new Class[]{}); - if (method != null) { - method.invoke(this, new Object[]{}); - } - } catch (Throwable t) { - } - } - - /** - * Executes the method with prefix after. - */ - private final void afterMethod() { - taskMethod("after"); - } - - /** - * Executes the method with prefix before. - */ - private final void beforeMethod() { - taskMethod("before"); - } - - /** - * Override this to do some work before every task. - */ - protected void beforeEveryTask() {} - - /** - * Override this for initialization -- called at - * the end of {@link #loadProject}. - */ - protected void init() {} - - /** - * Override this to do some work after every task. - */ - protected void afterEveryTask() {} - - protected void setProperties(Map map, boolean user) { - Iterator iter = map.keySet().iterator(); - while (iter.hasNext()) { - Object key = iter.next(); - Object val = map.get(key); - String keyString = key + ""; - String valString = val + ""; - if (user) { - project.setUserProperty(keyString, valString); - } else { - project.setProperty(keyString, valString); - } - } - } - - protected void setProperties() { - setProperties(getProperties(), false); - } - - protected void setUserProperties() { - setProperties(getUserProperties(), true); - } - - /** - * Override this to provide user properties -- default to - * an empty HashMap. - * - * @return Empty HashMap. - */ - protected Map getUserProperties() { - return new HashMap(); - } - - /** - * Override this to provide system properties -- default to - * an empty HashMap. - * - * @return Empty HashMap. - */ - protected Map getProperties() { - return new HashMap(); - } - - /** - * Loads the project with file name buildFile. - * - * @param buildFile Name of the XML file to load. - */ - public void loadProject(String buildFile) { - project = new Project(); - project.init(); - project.setUserProperty("ant.file", new File(buildFile).getAbsolutePath() ); - setProperties(); - setUserProperties(); - project.addBuildListener(this); - ProjectHelper.configureProject(project, new File(buildFile)); - init(); - } - - public void execute(String targetName) { - try { - project.executeTarget(targetName); - } finally { - } - } - - private static class StringBufferOutputStream extends OutputStream { - private StringBuffer buf; - public StringBufferOutputStream(StringBuffer buf) { - this.buf = buf; - } - public void write(int c) { - buf.append((char)c); - } - } - - public boolean verbosity(BuildEvent event) { - int[] verbosities = verbosities(); - int priority = event.getPriority(); - for (int i = 0; i < verbosities.length; i++) { - if (priority == verbosities[i]) return true; - } - return false; - } - - public int[] verbosities() { - return new int[] { /*Project.MSG_VERBOSE,*/ Project.MSG_INFO, Project.MSG_WARN, project.MSG_ERR }; - } - - // BuildListener - public void buildFinished(BuildEvent event) { - } - public void buildStarted(BuildEvent event) { - } - public void messageLogged(BuildEvent event) { - if (verbosity(event)) { - out.println(event.getMessage()); - } - } - public void targetFinished(BuildEvent event) { - } - public void targetStarted(BuildEvent event) { - } - public void taskFinished(BuildEvent event) { - } - public void taskStarted(BuildEvent event) { - } -} diff --git a/aspectj-attic/testing-src/org/aspectj/testing/compare/CompareFiles.java b/aspectj-attic/testing-src/org/aspectj/testing/compare/CompareFiles.java deleted file mode 100644 index 2d16c9e6b..000000000 --- a/aspectj-attic/testing-src/org/aspectj/testing/compare/CompareFiles.java +++ /dev/null @@ -1,571 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 1999-2001 Xerox Corporation, - * 2002 Palo Alto Research Center, Incorporated (PARC). - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Common Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * Xerox/PARC initial implementation - * ******************************************************************/ - -package org.aspectj.testing.compare; - -import org.aspectj.util.LangUtil; - -import jdiff.util.Diff; -import jdiff.text.FileLine; -import jdiff.util.DiffNormalOutput; - -import java.util.*; -import java.util.zip.*; -import java.io.*; - -/** - * Compare two files and emit differences. - * Requires the jdiff library in jdiff/jdiff.jar - */ -public class CompareFiles { - protected static String[] NO_STRINGS = new String[]{}; - /** standard rendering of null references */ - public static final String NULL = "null"; - /** filter for the both files */ - protected RegexpFilter filter; - /** ignore case by converting lines to upper case */ - protected boolean ignoreCase = false; - /** collapse internal whitespace by converting to space character */ - protected boolean collapseWhitespace = true; - /** trim leading and trailing whitespace from lines before comparison */ - protected boolean trimWhitespace = false; - /** output to this File - if not set, System.out */ - protected File output = null; - - /** - * Compare two files by lines, emitting output to System.out as a series of edits. - * @param args the String[] containing two files to diff plus any number of - *
  • -i "ignore": ignore case
  • - *
  • -t "trim" : ignore leading and trailing white space
  • - *
  • -b "blanks": ignore differences in all white space
  • - * @param lhs the File on the left-hand-side of the comparison - * @param rhs the File on the left-hand-side of the comparison - * @throws IllegalArgumentException if cannot read both files - */ - public static void main(String[] args) { - new CompareFiles().comparefiles(args); - } - - /** - * Write results of a diff to some output Writer - * @param result the DiffResult containing the results of the diff - * @param output the Writer to output results to - if null, - * defaults to System.out, but will be closed if not null - * @throws IllegalArgumentException if null == result or output - */ - public static void writeDiffResult(DiffResult result, File output) - throws IOException { - if (null == result) throw new IllegalArgumentException("null result"); - Writer writer = (null != output ? new FileWriter(output) - : new OutputStreamWriter(System.out)); - DiffNormalOutput out = new DiffNormalOutput(result.lhsLines, result.rhsLines); - out.setOut(writer); - out.setLineSeparator(LangUtil.EOL); - try { - out.writeScript(result.edits); - } finally { - if (null != output) { - try { writer.close(); } - catch (IOException e) { - e.printStackTrace(System.err); - } - } - } - } // writeDiffResult - - /** - * descend filesystem tree, invoking FileRunnerI.accept() on files. - * E.g., To list files from current directory: - *
    descendFileTree(new File("."), new FileRunnerI() {
    -     *     public boolean accept(File f){
    -     *        System.out.println(f.getAbsolutePath());
    -     *        return true;
    -     *     }});
    - * @param file root/starting point. If a file, the only one visited. - * @param filter supplies accept(File) routine - */ - public static void descendFileTree(File file, FileFilter filter) { - descendFileTree(file, filter, false); - } - - /** - * Descend filesystem tree, invoking FileFilter.accept() on files - * and, if userRecursion, on dirs. If userRecursion, accept() must - * call descendFileTree() again to recurse down directories. - * This calls fileFilter.accept(File) on all files before doing any dirs. - * E.g., To list only files from Unix root: - *
    descendFileTree(new File("/"), new FileFilter() {
    -     *     public boolean run(File f){
    -     *        System.out.println(f.getAbsolutePath());
    -     *        return true;
    -     *     }}, false);
    - * To list files/dir from root using user recursion: - *
    descendFileTree(new File("/"), new FileFilter() {
    -     *     public boolean run(File f){ 
    -     *        System.out.println(f.getAbsolutePath());
    -     *        if (f.isDirectory() && (-1 == f.getName().indexOf("CVS")))
    -     *           return descendFileTree(f, this, true);
    -     *        return true;
    -     *     }}, true);
    - * @param file root/starting point. If a file, the only one visited. - * @param filter supplies boolean accept(File) method - * @param userRecursion - if true, do accept() on dirs; else, recurse - * @return false if any fileFilter.accept(File) did. - * @throws IllegalArgumentException if file or fileFilter is null - */ - public static boolean descendFileTree(File file, FileFilter fileFilter, - boolean userRecursion) { - if (null == file) {throw new IllegalArgumentException("parm File"); } - if (null == fileFilter){throw new IllegalArgumentException("parm FileFilter");} - - if (!file.isDirectory()) { - return fileFilter.accept(file); - } else if (file.canRead()) { - // go through files first - File[] files = file.listFiles(ValidFileFilter.FILE_EXISTS); - if (null != files) { - for (int i = 0; i < files.length; i++) { - if (!fileFilter.accept(files[i])) { - return false; - } - } - } - // now recurse to handle directories - File[] dirs = file.listFiles(ValidFileFilter.DIR_EXISTS); - if (null != dirs) { - for (int i = 0; i < dirs.length; i++) { - if (userRecursion) { - if (!fileFilter.accept(dirs[i])) { - return false; - } - } else { - if (!descendFileTree(dirs[i], fileFilter,userRecursion)) { - return false; - } - } - } - } - } // readable directory (ignore unreadable ones) - return true; - } // descendFiles - - /** - * Render a zip/entry combination to String - */ - private static String renderZipEntry(File zipfile, ZipEntry entry) { - String filename = (null == zipfile ? "null File" : zipfile.getName()); - String entryname = (null == entry ? "null ZipEntry" : entry.getName()); - //return filename + "!" + entryname; - return "" + entryname; - } - - /** - * Initialise the filter. Users must do this before the filter is - * lazily constructed or must set update to true. - * @param args the String with any args valid for RegexpFilter.init(String, RegexpFilter) - * @param update if true, use existing filter settings unless - * overwritten by the new ones; - * if false, create a new filter using args. - * @throws IllegalArgumentException if cannot read both files - * @see RegexpFilter#init(String, RegexpFilter) - */ - public void initFilter(String arg, boolean update) { - filter = RegexpFilter.init(arg, update ? filter : null); - } - - /** - * Initialise the filter. Users must do this before the filter is - * lazily constructed or must set update to true. - * @param args the String[] with any args valid for RegexpFilter - * @param update if true, use existing filter settings unless - * overwritten by the new ones; - * if false, create a new filter using args. - * @throws IllegalArgumentException if cannot read both files - * @see RegexpFilter#init(String[], RegexpFilter) - */ - public void initFilter(String[] args, boolean update) { - filter = RegexpFilter.init(args, update ? filter : null); - } - - /** - * Compare two files by lines, emitting output to System.out as a series of edits. - * @param args the String[] containing two files to diff - * (lhs, rhs) plus any args valid for RegexpFilter - * @throws IllegalArgumentException if cannot read both files - */ - public final void comparefiles(String[] args) { - if (errMessage(null == args, "null args", null)) return; - if (errMessage(args.length < 2, "need more args", null)) return; - File lhs = new File(args[0]); - File rhs = new File(args[1]); - if (errMessage(!lhs.canRead(), "!lhs.canRead()", null)) return; - if (errMessage(!rhs.canRead(), "!rhs.canRead()", null)) return; - int filterArgsLength = args.length - 2; - if (0 >= filterArgsLength) { - initFilter(NO_STRINGS, false); - } else { - String[] filterArgs = new String[filterArgsLength]; - System.arraycopy(args, 0, filterArgs, 0, filterArgsLength); - initFilter(filterArgs, false); - } - - try { - if (errMessage(!diff(lhs, rhs), "diff(lhs,rhs)",null)) return; - } catch (IOException t) { - if (errMessage(false, null, t)) return; - } - } // main - - /** - * Compare two files/dirs, emitting output as a series of edits. - * If both files are directories, then this compares their contents - * (including the contents of any zip or jar files) as a series of paths - * (i.e., it will recognize added or removed or changed filenames, but - * not files whose contents have changed). - * Output will go to the File specifies as "output" or System.out if none specified. - * This is costly, creating an in-memory copy, one String per line, of both files. - * @param lhs the File/dir on the left-hand-side of the comparison - * @param rhs the File/dir on the left-hand-side of the comparison - * @throws IllegalArgumentException if either parm is null or not existing, - * or if one is a dir and the other a file - * @throws IOException if getFileLines or diff utilities do - * @return false if there was some error - */ - public final boolean diff(File lhs, File rhs) throws IOException { - DiffResult result = null; - String err = null; - if ((null == lhs) || (null == rhs) - || (!lhs.exists()) || (!rhs.exists()) - || (!lhs.canRead()) || (!rhs.canRead()) - || (lhs.isDirectory() != rhs.isDirectory())) { - err = "need 2 readable files or dirs or zip files - got lhs=" + lhs + " rhs=" + rhs; - } else if (lhs.isDirectory()) { - result = diffDirUtil(lhs, rhs); - } else { - boolean lhsIsZip = isZipFile(lhs); - if (lhsIsZip != isZipFile(rhs)) { - err = "need 2 readable files or dirs or zip files - got lhs=" + lhs + " rhs=" + rhs; - } else if (lhsIsZip) { - result = diffDirUtil(lhs, rhs); - } else { - result = diffUtil(lhs, rhs); - } - } - if (null != err) throw new IllegalArgumentException(err); - if (errMessage(null == result, null, null)) return false; - writeDiffResult(result, output); - return true; - } - - /** - * Compare two files, returning results for further evaluation or processing - * @param lhs the File on the left-hand-side of the comparison - * @param rhs the File on the left-hand-side of the comparison - * @throws IllegalArgumentException if either parm is null - * @throws IOException if getFileLines or diff utilities do - * @return false if there was some error - */ - public final DiffResult diffUtil(File lhs, File rhs) - throws IOException { - if (errMessage(null == lhs, "null lhs", null)) return null; - if (errMessage(null == rhs, "null rhs", null)) return null; - FileLine[] lhsLines = getFileLines(lhs); - FileLine[] rhsLines = getFileLines(rhs); - Diff.change edits = new Diff(lhsLines, rhsLines).diff_2(false); - return new DiffResult(lhsLines, rhsLines, edits); - } - - /** - * Read all lines of a file into a String[] (not very efficient), - * implementing flag policies. - * @param file the File to read - * @return a FileLine[] with elements for each line in the file - */ - public FileLine[] getFileLines(File file) throws IOException { - if (file.isDirectory()) return getFileLinesForDir(file); - final Vector results = new Vector(); - - BufferedReader in = null; - try { - in = getReader(file); - String line; - while (null != (line = in.readLine())) { - results.add(toFileLine(line)); - } - } finally { - if (null != in) { in.close(); } - } - final FileLine[] lines = new FileLine[results.size()]; - results.copyInto(lines); - return lines; - } - - /** - * Compare two directories or zip files by listing contents (including contents of zip/jar files) - * and differencing the results. This does NOT call diff on each file, but only - * recognizes when files or zip entries have been added or removed. - * @param lhsDir the File for an existing, readable directory (as left-hand-side) - * @param rhsDir the File for an existing, readable directory (as right-hand-side) - * @throws IllegalArgumentException if null == lhs or rhsDir - */ - public DiffResult diffDirUtil(File lhsDir, File rhsDir) { - FileLine[] lhsLines = getFileLinesForDir(lhsDir); - FileLine[] rhsLines = getFileLinesForDir(rhsDir); - // now do the comparison as if they were two files - Diff.change edits = new Diff(lhsLines, rhsLines).diff_2(false); - return new DiffResult(lhsLines, rhsLines, edits); - } - - /** - * Render all sub-elements of a directory as a list of FileLine[], including entries - * in zip and jar files. The directory prefix is not included in the FileLine. - * @param dir the File representing the directory to list - * @throws IllegalArgumentException if null == dir or !dir.isDirectory() - */ - public FileLine[] getFileLinesForDir(File dir) { - if (null == dir) throw new IllegalArgumentException("null dir"); - if (!dir.isDirectory() && ! isZipFile(dir)) throw new IllegalArgumentException("not a dir: " + dir); - Collection items = directoryToString(dir, null); - return toFileLine(items, dir.getPath(), true); - } - - /** @return true if test or if null != error */ - protected boolean errMessage(boolean test, String message, Throwable error) { - if (test && (null != message)) { System.err.println(message); } - if (null != error) { error.printStackTrace(System.err); } - return (test || (null != error)); - } - - /** - * Convert current setting into an initialization list for filter - */ - protected String[] getFilterArgs() { - return new String[] - { (trimWhitespace ? "-t" : "-T") - , (collapseWhitespace ? "-b" : "-B") - , (ignoreCase ? "-i" : "-I") - }; - } - - /** - * Lazy construction of filter - */ - protected RegexpFilter getFilter() { - if (null == filter) { - filter = RegexpFilter.init(getFilterArgs(), null); - } - return filter; - } - - /** - * Factory for reader used by getFileLines(File). - * Default implementation creates a BufferedReader. - * Subclasses may implement pre-processing filters here. - */ - protected BufferedReader getReader(File file) throws IOException { - return new BufferedReader(new FileReader(file)); - } - - /** - * Create a FileLine from the input string, - * applying policies for whitespace, etc. - * @param string the String to wrap as a FileLine - * @return FileLine with string as text and - * canonical as string modified by any canonicalizing policies. - */ - protected FileLine toFileLine(String string) { - String canonical = getFilter().process(string); - return new FileLine(string, canonical); - } - - - protected boolean isZipFile(File f) { - String s = null; - if ((null == f) || (null == (s = f.getPath()))) { - return false; - } else { - return (f.exists() && !f.isDirectory() && (s.endsWith(".jar"))); - } - } - - /** - * Convert to an array of FileLine by optionally removing prefix and/or sorting - * @param collection the Collection of String to process - */ - protected FileLine[] toFileLine(Collection collection, String ignorePrefix, boolean sort) { - if (null == collection) throw new IllegalArgumentException("null collection"); - List list = new ArrayList(); - list.addAll(collection); - if (null != ignorePrefix) { - for (int i = 0; i < list.size(); i++) { - String next = list.get(i).toString(); - if (next.startsWith(ignorePrefix)) { - list.set(i, next.substring(ignorePrefix.length())); - } - } - } - if (sort) { - Collections.sort(list); - } - FileLine[] result = new FileLine[list.size()]; - int i = 0; - for (Iterator it = list.iterator(); it.hasNext();) { - result[i++] = toFileLine(it.next().toString()); - } - if (i < result.length) { - throw new Error("list lost elements? " + (result.length-i)); - } - return result; - } - - /** - * Return the names of all files below a directory. - * If file is a directory, then all files under the directory - * are returned. If file is absolute or relative, all the files are. - * If file is a zip or jar file, then all entries in the zip or jar - * are listed. Entries inside those jarfiles/zipfiles are not listed. - * There are no guarantees about ordering. - * @param dir the File to list for - * @param results the Collection to use for the results (may be null) - * @throws IllegalArgumentException if null == dir - * @return a Collection of String of paths, including paths inside jars - */ - protected Collection directoryToString(File dir, Collection results) { - if (null == dir) throw new IllegalArgumentException("null dir"); - final Collection result = (results != null? results : new Vector()); - if (isZipFile(dir)) { - zipFileToString(dir, result); - } else if (!dir.isDirectory()) { - throw new IllegalArgumentException("not a dir: " + dir); - } else { - AccumulatingFileFilter acFilter = new AccumulatingFileFilter() { - public boolean accumulate(File file) { - String name = file.getPath(); - result.add(name); - if (isZipFile(file)) { - zipFileToString(file, result); - } - return true; - } - }; - descendFileTree(dir, acFilter, false); - } - return result; - } // directoryToString - - /** - * Render as String the entries in a zip or jar file, - * converting each to String beforehand (as jarpath!jarentry) - * applying policies for whitespace, etc. - * @param file the File to enumerate ZipEntry for - * @param results the Colection to use to return the FileLine - may be null - * @return FileLines with string as text and - * canonical as string modified by any canonicalizing policies. - */ - protected Collection zipFileToString(final File zipfile, Collection results) { - Collection result = (results != null ? results : new Vector()); - ZipFile zip = null; - try { - //ZipFile.OPEN_READ | ZipFile.OPEN_DELETE); delete is 1.3 only - zip = new ZipFile(zipfile); - Enumeration enum = zip.entries(); - // now emitting filename only once, so entries match even if filename does not - results.add("ZipFileName: " + zipfile); - while (enum.hasMoreElements()) { - results.add(renderZipEntry(zipfile, (ZipEntry) enum.nextElement())); - } - zip.close(); - zip = null; - } catch (Throwable t) { - String err = "Error opening " + zipfile + " attempting to continue..."; - System.err.println(err); - t.printStackTrace(System.err); - } finally { - if (null != zip) { - try { zip.close(); } - catch (IOException e) { - e.printStackTrace(System.err); - } - } - } - return result; - } - - /** - * return structure for diffUtil - */ - public final class DiffResult { - public final FileLine[] lhsLines; - public final FileLine[] rhsLines; - public final Diff.change edits; - public DiffResult (FileLine[] lhsLines, - FileLine[] rhsLines, - Diff.change edits) { - this.lhsLines = lhsLines; - this.rhsLines = rhsLines; - this.edits = edits; - } - } - -} // class CompareFiles - -class ValidFileFilter implements FileFilter { - public static final FileFilter EXIST = new ValidFileFilter(); - public static final FileFilter FILE_EXISTS = new FilesOnlyFilter(); - public static final FileFilter DIR_EXISTS = new DirsOnlyFilter(); - protected ValidFileFilter(){} - public boolean accept(File f) { - return ((null != f) && (f.exists())); - } - static class FilesOnlyFilter extends ValidFileFilter { - public final boolean accept(File f) { - return (super.accept(f) && (!f.isDirectory())); - } - } - static class DirsOnlyFilter extends ValidFileFilter { - public final boolean accept(File f) { - return (super.accept(f) && (f.isDirectory())); - } - } -} - -/** - * A FileFilter that accumulates the results when called if they exist. - * Subclasses override accumulate to determine whether it should be - * accumulated. - */ -class AccumulatingFileFilter extends ValidFileFilter { - Vector files = new Vector(); - public final boolean accept(File f) { - if (super.accept(f) && (accumulate(f))) { - files.add(f); - } - return true; - } - - /** - * This implementation accumulates everything. - * Subclasses should override to implement filter - * @param file a File guaranteed to exist - * @return true if file should be accumulated. - */ - public boolean accumulate(File f) { - return true; - } - /** - * @return list of files currently accumulated - */ - public File[] getFiles() { - return (File[]) files.toArray(new File[0]); - } -} diff --git a/aspectj-attic/testing-src/org/aspectj/testing/compare/CompareUtil.java b/aspectj-attic/testing-src/org/aspectj/testing/compare/CompareUtil.java deleted file mode 100644 index 8358a177d..000000000 --- a/aspectj-attic/testing-src/org/aspectj/testing/compare/CompareUtil.java +++ /dev/null @@ -1,143 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 1999-2001 Xerox Corporation, - * 2002 Palo Alto Research Center, Incorporated (PARC). - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Common Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * Xerox/PARC initial implementation - * ******************************************************************/ - -package org.aspectj.testing.compare; - -import java.util.Iterator; -import java.util.Collection; -import java.util.List; - -/** Minor methods for short-circuiting comparisons */ -public class CompareUtil { - /** - * Callers may abort equality checks with false - * if this passes its misc short-circuit semantics. - * A false result does not mean the arguments - * are equal, but a true result does mean they are not equal. - *
    if (notSame(foo,bar,true)) then return false;
    - * @param lhs the Object on the left-hand-side to compare - * @param rhs the Object on the right-hand-side to compare - * @param considerType if true, then also return true if the - * right-hand-side cannot be assigned to the left-hand-side - * @return true if lhs and rhs are not the same per considerType. - */ - public static boolean notSame(Object lhs, Object rhs, boolean considerType) { - if (null == lhs) { - return (!(null == rhs)); - } else if (null == rhs) { - return true; - } else if (lhs== rhs) { - return false; // known to be same - } else if (considerType) { - Class lhClass = lhs.getClass(); - Class rhClass = rhs.getClass(); - if (!lhClass.isAssignableFrom(rhClass)) { - return true; - } - } - return false; // unknown whether equal or not - } - - /** - * Return null/equal comparison: - *
  • null considered to be lesser
  • - *
  • reference or Object.equals() considered to be 0
  • - *
  • return Integer.MAX_VALUE for all other cases
  • - * - * - * - * - * - * - * - * - *
    resultinput
    -1null < rhs
    1lhs > null
    0null == null
    0lhs == rhs
    0lhs.equals(rhs)
    Integer.MAX_VALUE{all other cases}
    - * @see Comparator - * @return Integer.MAX_VALUE if uncertain, value otherwise - */ - public static int compare(Object lhs, Object rhs) { - if (null == lhs) { - return (null == rhs ? 0 : -1); - } else if (null == rhs) { - return 1; - } else if (lhs == rhs) { - return 0; // known to be same - } else { - return Integer.MAX_VALUE; - } - } - - /** - * Return boolean comparison where true > false. - * (Comparable not defined for Boolean) - * @see Comparator - */ - public static int compare(boolean lhs, boolean rhs) { - return (lhs == rhs ? 0 : (lhs ? 1 : -1)); - } - - /** - * Return String comparison based on {@link compare(Object,Object)} - * and {@link String.compareTo(String)}. - * @see Comparator - */ - public static int compare(String lhs, String rhs) { - int result = compare((Object) lhs, (Object) rhs); - if (Integer.MAX_VALUE == result) { - result = lhs.compareTo(rhs); - } - return result; - } - - /** - * Compare two Collections by reference to a standard List. - * The first Collection to not contain a standard element - * when the other does loses. Order is ignored. - * The left-hand-side acts as the standard if the standard is null. - * @param lhs the List from the left-hand-side - * @param rhs the Collection from the right-hand-side - * @param standard the List to act as the standard (if null, use lhs) - * @param return -1 if lhs is null and rhs is not, 1 if reverse; - * 0 if both have all elements in standard, - * 1 if lhs has a standard element rhs does not, -1 if reverse - * (testing in standard order) - */ - public static int compare(List lhs, Collection rhs, List standard) { - int result = compare(lhs, rhs); - if (result == Integer.MAX_VALUE) { - if (null == standard) { - result = compare(lhs, rhs, lhs); // use lhs as standard - } else { - boolean leftHasThem = lhs.containsAll(standard); - boolean rightHasThem = rhs.containsAll(standard); - if (leftHasThem != rightHasThem) { - result = (leftHasThem ? 1 : -1); - } else if (leftHasThem) { - result = 0; // they both have them - } else { // first to not have an element loses - Iterator standardIterator = standard.iterator(); - while (standardIterator.hasNext()) { - Object standardObject = standardIterator.next(); - boolean leftHasIt = lhs.contains(standardObject); - boolean rightHasIt = rhs.contains(standardObject); - if (leftHasIt != rightHasIt) { - result = (leftHasIt ? 1 : -1); - break; - } - } - } - } - } - return result; - } -} // class Util diff --git a/aspectj-attic/testing-src/org/aspectj/testing/compare/GenericTreeNode.java b/aspectj-attic/testing-src/org/aspectj/testing/compare/GenericTreeNode.java deleted file mode 100644 index cdb0b70da..000000000 --- a/aspectj-attic/testing-src/org/aspectj/testing/compare/GenericTreeNode.java +++ /dev/null @@ -1,427 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 1999-2001 Xerox Corporation, - * 2002 Palo Alto Research Center, Incorporated (PARC). - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Common Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * Xerox/PARC initial implementation - * ******************************************************************/ - - -package org.aspectj.testing.compare; - -import java.util.*; - - -/** - * Generic tree and pairwise traversal over it - * for comparison purposes. - * Implement a generic tree by delegation and - * a traversal method for comparing two trees. - * Guarantees after initialization: - *
  • nodeComparator is not null
  • - *
  • node is not null
  • - *
  • children, if any, are assignable to childClass - * (only as of initialization, since list is adopted)
  • - *
  • Obeys GenericTreeNode contract, especially regarding equals
  • - *

    It will throw Error if used before initialization completes. - */ -public class GenericTreeNode implements Comparable { - /** underlying node - never null */ - Object node; - /** node children - type-safe if present */ - List children; - /** node parent - may be null if this is tree root */ - GenericTreeNode parent; - /** used to compare underlying node */ - Comparator nodeComparator; - /** Class used to verify children - may be null */ - Class childClass; - - /** Track whether we are initialized */ - boolean ready; - /** cache for heavy toString() */ - String toStringCache; - - // --------------------------------------- static - /** Singleton visitor to match trees exactly, stopping at first failure */ - public static final GenericTreeNodesVisitorI EXACT = new MatchExact(); - - /** Singleton visitor to print non-matching nodes to System.err */ - public static final GenericTreeNodesVisitorI PRINTERR = new PrintNonMatches(); - - /** Singleton visitor to print all nodes to System.err */ - public static final GenericTreeNodesVisitorI PRINTALL = new PrintAllPairs(); - - - /** Singleton comparator for all of us */ - public static final Comparator COMPARATOR = new gtnComparator(); - - /** - * Visit two generic trees in order. - * Visit the parents, and recursively visit the children. - * The children are visited in an order determined by - * (any) ordering factory invoked to produce an ordered pair - * of children lists for visiting. - * All children are visited, even if not paired. - * When one list of children is smaller, the - * remainder are visited with null complements. - * This is true for parents as well; this will visit - * all the children of a parent even when the - * other parent is null. - * This will return false without further visits - * as soon as the visitor returns false. That means - * the visitor can decide to stop visiting when null - * nodes (parent or children) are encountered). - * This will return true only after the tree was - * visited without objection from the visitor. - *

    A simple example of using this to determine if - * two trees are strictly equal is this: - * @return false if the visitor returned false for any visit; - * true otherwise. - * @throws Error if any children are not GenericTreeNode - * @throws IllegalArgumentException if the visitor or both parents are null - */ - - public static boolean traverse(GenericTreeNode lhsParent - , GenericTreeNode rhsParent - , GenericTreeNodeListOrdererFactoryI childrenPrepFactory - , GenericTreeNodesVisitorI visitor) { - if (null == visitor) { - throw new IllegalArgumentException("null visitor"); - } - if ((null == lhsParent) && (null == rhsParent)) { - throw new IllegalArgumentException("null parents"); - } - if (visitor.visit(lhsParent, rhsParent)) { - List lhsList = (null == lhsParent ? null : lhsParent.getChildren()); - List rhsList = (null == rhsParent ? null : rhsParent.getChildren()); - if (null != childrenPrepFactory) { - GenericTreeNodeListOrdererI factory = - childrenPrepFactory.produce(lhsParent, rhsParent, visitor); - if (null != factory) { - List[] prepKids = factory.produceLists(lhsList, rhsList); - if (null != prepKids) { - lhsList = prepKids[0]; - rhsList = prepKids[1]; - } - } - - } - ListIterator lhsIterator = (null == lhsList ? null : lhsList.listIterator()); - ListIterator rhsIterator = (null == rhsList ? null : rhsList.listIterator()); - Object lhs = null; - Object rhs = null; - while (true) { - lhs = null; - rhs = null; - // get the child pair - if ((null != lhsIterator) && (lhsIterator.hasNext())) { - lhs = lhsIterator.next(); - } - if ((null != rhsIterator) && (rhsIterator.hasNext())) { - rhs = rhsIterator.next(); - } - if ((null == rhs) && (null == lhs)) { - break; - } - if ((null != lhs) && (!(lhs instanceof GenericTreeNode))) { - throw new Error("GenericTreeNode expected, got lhs " + lhs); - } - if ((null != rhs) && (!(rhs instanceof GenericTreeNode))) { - throw new Error("GenericTreeNode expected, got rhs " + rhs); - } - // traverse the child pair - if (!traverse((GenericTreeNode) lhs, (GenericTreeNode) rhs, - childrenPrepFactory, visitor)) { - return false; - } - } - } - return true; // see also other return statements above - } // traverse - - // --------------------------------------- constructors - public GenericTreeNode() { - //ready = false; - } - - public void init(GenericTreeNode parent, Comparator nodeComparator, - Object node, List children, Class childClass) { - if (ready) ready = false; // weak sync - if (null == node) { - throw new IllegalArgumentException("null node"); - } - if (null == nodeComparator) { - throw new IllegalArgumentException("null nodeComparator"); - } - this.nodeComparator = nodeComparator; - this.node = node; - this.children = children; - this.parent = parent; - if (null != childClass) { - ListIterator iter = children.listIterator(); - while (iter.hasNext()) { - Object kid = iter.next(); - if (!(childClass.isAssignableFrom(kid.getClass()))) { - String err = "child " + kid + " is not " + childClass; - throw new IllegalArgumentException(err); - } - } - this.childClass = childClass; - } - ready = true; - } - - //-------------------- Object interface - /** - * ambiguous: equal if - *

  • this is the input, or
  • - *
  • the input is a GenericTreeNode, and
  • - *
  • the underlying nodes are equal(), or
  • the underlying nodes have equal comparators - * which return 0 from compare(...) - * @param input the Object to compare with - * @return true if this equals input - */ - public boolean equals(Object input) { - if (input == this) { - return true; - } else if (!(input instanceof GenericTreeNode)) { - return false; - } else { - GenericTreeNode in = (GenericTreeNode) input; - if (node.equals(in.getNode())) { // assumes nodes are unique, not flyweights? - return true; - } else { - Comparator inComp = in.getNodeComparator(); - if ((this == nodeComparator) - || (this == inComp) - || (nodeComparator == inComp) - || (nodeComparator.equals(inComp))) { - return (0 == nodeComparator.compare(this, in)); - } else { - return false; - } - } - } - } - - /** - * Delegate to the underlying node object - * @return the hashcode of the underlying node object - */ - public int hashCode() { // todo: probably not correct to delegate to node - return node.hashCode(); - } - - /** toString delegates to longString() */ - public String toString() { - if (null == toStringCache) { - toStringCache = longString(); - } - return toStringCache; - } - - /** - * short rendition delegates to thisString, - * prefixing by one tab per parent - */ - public String shortString() { - StringBuffer sb = new StringBuffer(); - // add a tab for each parent - GenericTreeNode par = parent; - while (null != par) { - sb.append("\t"); - par = par.getParent(); - } - sb.append(thisString()); - return sb.toString(); - } - - /** - * long rendition delegates to parentString, thisString, - * and childString as follows: - *
    GenericTreeNode [parent={parentString()] [children={size}] [Node={thisString()]
    - */ - public String longString() { - StringBuffer sb = new StringBuffer(); - sb.append("GenericTreeNode "); - sb.append("[parent="); - sb.append(parentString()); - sb.append("] [children="); - if (null == children) { - sb.append("0"); - } else { - sb.append("" + children.size()); - } - sb.append("] [Node="); - sb.append(thisString()); - sb.append("]"); - return sb.toString(); - } - - /** render this as "[root] [next] ... [parent]" */ - protected String thisString() { - return node.toString(); - } - - /** render parent hierarchy as "[root] [next] ... [parent]" */ - protected String parentString() { - if (null == parent) { - return "[null]"; - } else { - Vector parents = new Vector(); - GenericTreeNode par = parent; - do { - parents.addElement(par); - par = par.getParent(); - } while (null != par); - int size = parents.size(); - StringBuffer sb = new StringBuffer(32*size); - par = (GenericTreeNode) parents.remove(--size); - sb.append("["); - do { - sb.append(par.toString()); - par = (size<1?null:(GenericTreeNode) parents.remove(--size)); - if (null != par) { - sb.append("] ["); - } - } while (null != par); - sb.append("]"); - return sb.toString(); - } - } // parentString() - - // -------------------------- Comparable interface - /** - * Comparable just delegates to Comparator. - * i.e., return compare(this, rhs) - * @param rhs the Object to compare from the right - * @throws ClassCastException if either is not instanceof GenericTreeNode - * @return 0 if equal, >0 if this is greater than rhs, <0 otherwise. - */ - public int compareTo(Object rhs) { - return COMPARATOR.compare(this, rhs); - } - - - //-------------------- GenericTreeNode interface - /** @return the actual underlying node */ - public Object getNode() { assertReady(); return node ; } - /** @return the actual underlying node */ - public GenericTreeNode getParent() { assertReady(); return parent ; } - /** @return List of children - null if none */ - public List getChildren() { assertReady(); return children ; } - /** @return Comparator used for comparing node (not children) */ - public Comparator getNodeComparator() { assertReady(); return nodeComparator; } - /** @return Class which any children can be assigned to */ - public Class getChildClass() { assertReady(); return childClass; } - - //-------------------- misc - protected void assertReady() { - if (!ready) throw new Error("not ready"); - } - - //-------------------- inner classes - /** - * This relies entirely on the GenericTreeNode implementation of equals() - * which delegates to the underlying node equals() or the comparator - */ - static class MatchExact implements GenericTreeNodesVisitorI { - public boolean visit(GenericTreeNode lhs,GenericTreeNode rhs) { - return (null == lhs ? (null == rhs) : lhs.equals(rhs)); - } - } - - /** - * This prints non-matching pairs to System.err, - * returning true always. - */ - static class PrintNonMatches implements GenericTreeNodesVisitorI { - public boolean visit(GenericTreeNode lhs,GenericTreeNode rhs) { - if (! (null == lhs ? (null == rhs) : lhs.equals(rhs))) { - System.err.println("[lhs=" + lhs + "] [rhs=" + rhs + "]"); - } - return true; - } - } - - /** - * This prints all pairs to System.err, returning true always. - */ - static class PrintAllPairs implements GenericTreeNodesVisitorI { - public boolean visit(GenericTreeNode lhs,GenericTreeNode rhs) { - System.err.println("[lhs=" + lhs + "] [rhs=" + rhs + "]"); - return true; - } - } - - /** - * have to separate to distinguish - * gtn.equals() from gtnComparator.equals - */ - static class gtnComparator implements Comparator { - public boolean equals(Object o) { - if (null == o) return false; - return ( o instanceof gtnComparator ); - } - public int hashCode() { - return gtnComparator.class.hashCode(); - } - // -------------------------- Comparator interface - /** - * Shallow compare of two GenericTreeNodes. - *
  • any null component translates to "less than" another null component
  • - *
  • comparators must be equal according to - * Comparator.equals(Comparator)
  • - *
  • underlying nodes equal according to - * Comparator.compare(Object lhs, Object rhs)
  • - *
  • if the two comparators are not equal, then - * do arbitrary ordering of the node by toString().compareTo() - * of the underlying objects
  • - *
  • children are ignored. Two nodes may be equal even if - * they do not have the same children.
  • - * @param lhs the Object to compare from the left - * @param rhs the Object to compare from the right - * @throws ClassCastException if either is not instanceof GenericTreeNode - */ - public int compare(Object lhs, Object rhs) { - int result = CompareUtil.compare(lhs, rhs); - if (Integer.MAX_VALUE == result) { - GenericTreeNode lhsNode = (GenericTreeNode) lhs; - GenericTreeNode rhsNode = (GenericTreeNode) rhs; - Object lhObject = lhsNode.getNode(); - Object rhObject = rhsNode.getNode(); - result = CompareUtil.compare(lhObject, rhObject); // - if (Integer.MAX_VALUE == result) { - Comparator lhComp = lhsNode.getNodeComparator(); - Comparator rhComp = rhsNode.getNodeComparator(); - result = CompareUtil.compare(lhComp, rhComp); - if ((Integer.MAX_VALUE == result) - || ((0 == result) && (null == lhComp))) { - // tricky: comparators are not equal or null, - todo - // so unable to determine standard of ordering. - // impose a consistent but arbitrary ordering - // on the underlying objects - System.err.println(" -- result: " + result + " lhComp " + lhComp); - result = lhObject.toString().compareTo(rhObject.toString()); - } else if (0 == result) { // ok to use comparator - result = lhComp.compare(lhsNode.getNode(), rhsNode.getNode()); - } else { - String err = "Program error - result: " + result - + " lhComp: " + lhComp + " rhComp: " + rhComp; - throw new Error(err); - } - } - } - return result; - } // compare - } - -} // class GenericTreeNode - diff --git a/aspectj-attic/testing-src/org/aspectj/testing/compare/GenericTreeNodeListOrdererFactoryI.java b/aspectj-attic/testing-src/org/aspectj/testing/compare/GenericTreeNodeListOrdererFactoryI.java deleted file mode 100644 index c98549829..000000000 --- a/aspectj-attic/testing-src/org/aspectj/testing/compare/GenericTreeNodeListOrdererFactoryI.java +++ /dev/null @@ -1,30 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 1999-2001 Xerox Corporation, - * 2002 Palo Alto Research Center, Incorporated (PARC). - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Common Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * Xerox/PARC initial implementation - * ******************************************************************/ - -package org.aspectj.testing.compare; - -/** - * Factory to produce orderers per children list pair. - * Using a factory permits generation/selection of the right orderer - * for each set of children to be compared, potentially considering - * the visitor expectations. Note that while orderers may change during - * traversals, visitors do not. - */ -public interface GenericTreeNodeListOrdererFactoryI { - /** - * Produce the correct orderer for the children of the given GenericTreeNodes - * @return GenericTreeNodeListOrdererI for children, or null if none to be used - */ - public GenericTreeNodeListOrdererI produce(GenericTreeNode lhs, GenericTreeNode rhs, - GenericTreeNodesVisitorI visitor); -} diff --git a/aspectj-attic/testing-src/org/aspectj/testing/compare/GenericTreeNodeListOrdererI.java b/aspectj-attic/testing-src/org/aspectj/testing/compare/GenericTreeNodeListOrdererI.java deleted file mode 100644 index 7f5e2bd07..000000000 --- a/aspectj-attic/testing-src/org/aspectj/testing/compare/GenericTreeNodeListOrdererI.java +++ /dev/null @@ -1,44 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 1999-2001 Xerox Corporation, - * 2002 Palo Alto Research Center, Incorporated (PARC). - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Common Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * Xerox/PARC initial implementation - * ******************************************************************/ - -package org.aspectj.testing.compare; - -import java.util.List; - -/** - * Puts two lists of GenericTreeNode children - * in traversal order for comparison purposes. - * Given two lists, produce two lists which - * should be the comparison order of the two. - * In the case of set comparison, this will - * impose an ordering on the produced lists - * such that the equal elements are pairs. - * In the case of list comparison, it may - * impose an ordering if the comparator itself - * does not. - * All Lists must contain only GenericTreeNode. - */ -public interface GenericTreeNodeListOrdererI { - /** - * Produce lists representing the proper transformation of - * the children for a given visitor. - * To use the existing lists, return them in a new array. - * You may return null for one or both Lists. - * @param lhs the List representing the left-hand-side - * which contains only GenericTreeNode - * @param rhs the List representing the right-hand-side - * which contains only GenericTreeNode - * @return two lists List[] (0 => lhs, 1 => rhs) - */ - public List[] produceLists(List lhs, List rhs); -} diff --git a/aspectj-attic/testing-src/org/aspectj/testing/compare/GenericTreeNodesVisitorI.java b/aspectj-attic/testing-src/org/aspectj/testing/compare/GenericTreeNodesVisitorI.java deleted file mode 100644 index da1dcf2a5..000000000 --- a/aspectj-attic/testing-src/org/aspectj/testing/compare/GenericTreeNodesVisitorI.java +++ /dev/null @@ -1,31 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 1999-2001 Xerox Corporation, - * 2002 Palo Alto Research Center, Incorporated (PARC). - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Common Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * Xerox/PARC initial implementation - * ******************************************************************/ - -package org.aspectj.testing.compare; -/** - * Visit a node-pair in the trees, - * signalling whether to continue traversal. - */ -public interface GenericTreeNodesVisitorI { - /** - * Visit nodes in parallel trees. - * One (but not both) of the input nodes may be null. - * @param lhs the GenericTreeNode on the left-hand-side of a binary operation - * (may be null) - * @param lhs the GenericTreeNode on the right-hand-side of a binary operation - * (may be null) - * @return true if should continue visiting - */ - public boolean visit(GenericTreeNode lhs, GenericTreeNode rhs); -} - diff --git a/aspectj-attic/testing-src/org/aspectj/testing/compare/Regexp.java b/aspectj-attic/testing-src/org/aspectj/testing/compare/Regexp.java deleted file mode 100644 index c32310cd7..000000000 --- a/aspectj-attic/testing-src/org/aspectj/testing/compare/Regexp.java +++ /dev/null @@ -1,40 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 1999-2001 Xerox Corporation, - * 2002 Palo Alto Research Center, Incorporated (PARC). - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Common Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * Xerox/PARC initial implementation - * ******************************************************************/ - -package org.aspectj.testing.compare; - -import java.util.Vector; - -/** Generalize regular expression interface (to avoid binding to regexp provider)*/ -public interface Regexp { - /** @return the substrings matched in argument by this regular expression */ - public Vector getGroups(String argument); - - /** @return true if argument is matched by this regular expression */ - public boolean matches(String argument); - - /** - * Set pattern used in this regular expression. - * May throw Exception if the pattern can be determined to be illegal - * during initialization. - * @throws Exception if pattern is illegal - */ - public void setPattern(String pattern) throws Exception; - - /** - * @return a string representaion of the pattern - * (may not be legal or the input) - */ - public String getPattern() ; -} - diff --git a/aspectj-attic/testing-src/org/aspectj/testing/compare/RegexpFactory.java b/aspectj-attic/testing-src/org/aspectj/testing/compare/RegexpFactory.java deleted file mode 100644 index 0c7bccc14..000000000 --- a/aspectj-attic/testing-src/org/aspectj/testing/compare/RegexpFactory.java +++ /dev/null @@ -1,64 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 1999-2001 Xerox Corporation, - * 2002 Palo Alto Research Center, Incorporated (PARC). - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Common Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * Xerox/PARC initial implementation - * ******************************************************************/ - -// todo: non-distribution license? - -package org.aspectj.testing.compare; - -// currently in aspectj-external-lib/regexp -import org.apache.regexp.RE; - -import java.util.Vector; - - -/** Factory for our Regexp. */ -public class RegexpFactory { - public static Regexp makeRegexp() { - return new RegExpDelegate(); - } -} - -/** Implement Regexp by delegating to org.apache.regexp.RE */ -final class RegExpDelegate implements Regexp { - String pattern; - RE regexp; - public RegExpDelegate() { } - public Vector getGroups(String arg) { - String label = "getGroups(\"" + arg + "\") "; - D.log(label); - Vector result = null; - if ((null != arg) && (matches(arg))) { - int size = regexp.getParenCount(); - D.log(label + " size " + size); - result = new Vector(size); - for (int i = 0; i < size; i++) { - Object item = regexp.getParen(i); - result.addElement(item); - D.log(label + i + ": " + item); - } - } - return result; - } - public boolean matches(String arg) { - return ((null != regexp) && regexp.match(arg)); - } - public void setPattern(String pattern) throws Exception { - this.pattern = pattern; - regexp = new RE(this.pattern); - D.log("RE: " + regexp + " pattern: /" + pattern + "/"); - } - public String getPattern() { - return pattern; - } -} - diff --git a/aspectj-attic/testing-src/org/aspectj/testing/compare/RegexpFilter.java b/aspectj-attic/testing-src/org/aspectj/testing/compare/RegexpFilter.java deleted file mode 100644 index 7ea6c7ecf..000000000 --- a/aspectj-attic/testing-src/org/aspectj/testing/compare/RegexpFilter.java +++ /dev/null @@ -1,622 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 1999-2001 Xerox Corporation, - * 2002 Palo Alto Research Center, Incorporated (PARC). - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Common Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * Xerox/PARC initial implementation - * ******************************************************************/ - -// todo: non-distribution license? -package org.aspectj.testing.compare; - -import org.aspectj.testing.compare.Regexp; - -import java.util.*; -import java.io.*; - - -/** utility class for logging */ -class D { - public static boolean LOG = false; - public static void log(String s) { if (LOG) System.err.println("## " + s); } - static { - try { - LOG = (null != System.getProperty("DEBUG")); - } catch (Throwable t) { - // ignore - } - } -} - -/** utility class for handling errors */ -class ErrHandler { - public static final ErrHandler DEFAULT = new ErrHandler(); - public static final Action INFO = new Action("info") { - public void invoke(String message) { System.out.println("INFO: " + message); } }; - public static final Action WARN = new Action("warn") { - public void invoke(String message) { System.err.println("WARNING: " + message); } }; - public static final Action HALT = new Action("halt") { - public void invoke(String message) { throw new RuntimeException(message); } }; - public static final Action ABORT = new Action("abort") { - public void invoke(String message) { throw new Error(message); } }; - public static final Action EXIT = new Action("exit") { - public void invoke(String message) { System.err.println(message); System.exit(1); } }; - abstract static class Action { - protected final String name; - private Action(String name) { - this.name = name.toLowerCase().trim(); - } - abstract public void invoke(String message); - public String toString() { return name; } - } - public static final void handleErr(String message, Throwable t) { - DEFAULT.handle(message, t); - } - public static final void handleErr(String message) { - DEFAULT.handle(message); - } - public static final void handleErr(String message, Action suggestion) { - DEFAULT.handle(message, suggestion); - } - public void handle(String message) { handle(message, INFO); } - public void handle(String message, Throwable t) { - String eMessage = (null == t ? "" : - t.getClass().getName() + ": " + t.getMessage()); - handle(message + eMessage, HALT); - } - /** - * The default implementation just takes the suggested action - * @param message the String to pass to any Action - * @param suggestion the Action proposed by the caller - */ - public void handle(String message, Action suggestion) { - suggestion.invoke(message); - } -} - -/* old comments, not correct: - *
  • test line against all registered select statements - * to get all the matching (replace) operations (unsupported)
  • - * The algorithm is greedy in that if the user requests a line - * and the default is no-output, it will read lines from the input - * until one is matched (or EOF). - */ - -/** - * Process files in a minimal version of sed: - *
  • read line using superclass LineNumberReader.readLine()
  • - *
  • Preprocess with case and white space operations
  • - *
  • run all the replace operations on the input, in order
  • - *
  • return the line.
  • - * Using anything but the readLine() method will circumvent - * the regular expression replacement processing. - */ -public class RegexpFilter { - protected static final String[] NO_STRINGS = new String[]{}; - - // ---------------------------------------------- static methods - /** - * Process file (or System.in) like sed. - * This only calls RegexpFilterReader.main(args). - * @param args same as for init(String[], RegexpFilter) - */ - public static void main(String[] args) throws IOException { - RegexpFilterReader.main(args); - } - - // todo: move String -> String[] (commas) out into utility - /** - * Initialize a RegexpFilter based on command-line style arguments - * in a single String. (Otherwise, same as - * init(String[], RegexpFilter)) - * The Strings are separated at , (unless \ escaped) and trimmed. - * Note that the escape characters are removed from before the ,. - * @param spec the String to break into String[] - * @param toSet the RegexpFilter to initialize - if null, construct one from - * the file argument or stdin if there is no file argument. - */ - public static RegexpFilter init(String arg, RegexpFilter toSet) { - if ((null == arg) || (1 > arg.length())) { - return init(NO_STRINGS, toSet); - } - StringTokenizer st = new StringTokenizer(arg, ","); - Vector result = new Vector(); - String last = null; - String next; - while (st.hasMoreTokens()) { - next = st.nextToken(); - if (next.endsWith("\\") && (st.hasMoreTokens())) { - next = next.substring(0, next.length()-1); - last = last == null ? next : last + next; - continue; - } - if (null != last) { - next = last + next; - last = null; - } - result.add(next.trim()); - } - String[] args = new String[result.size()]; - result.copyInto(args); - return RegexpFilter.init(args, toSet); - } - - /** - * Initialize a RegexpFilter based on command-line style arguments. - * This is the only way (currently) to set up a RegexpFilter. - * syntax: {file | {-i|-t|-b|-s |-s }..} - * (for booleans, use lowercase to enable, uppercase to disable). - * @param args the String[] containing file to input plus any number of... - *
  • -i "ignore": ignore case
  • - *
  • -t "trim" : ignore leading and trailing white space
  • - *
  • -b "blanks": ignore differences in all white space
  • - *
  • -s "{s/pattern/expression/};...": - * replace pattern in lines with expression
  • - *
  • -S : same as s, but read commands from file
  • - * @param toSet the RegexpFilter to initialize - if null, construct one from - * the file argument or stdin if there is no file argument. - */ - public static RegexpFilter init(String[] args, RegexpFilter toSet) { - final String syntax = " - syntax: {file | {-i|-t|-b|-s |-s }..}"; - RegexpFilter result = (null != toSet ? toSet : new RegexpFilter()); - if ((null != args) && (0 < args.length)) { - for (int i = 0; i < args.length; i++) { - String arg = args[i]; - if ((null == arg) || (1 > arg.length())) continue; - if (arg.startsWith("-")) { - switch (arg.charAt(1)) { - case 'i' : result.ignoreCase = true; break; - case 'I' : result.ignoreCase = false; break; - case 'b' : result.collapseWhitespace = true; break; - case 'B' : result.collapseWhitespace = false; break; - case 't' : result.trimWhitespace = true; break; - case 'T' : result.trimWhitespace = false; break; - case 's' : ++i; - if (i < args.length) { - result.getOperationList().addOperation(args[i]); - } else { - String err = "need arg after -s " + syntax; - ErrHandler.handleErr(err, ErrHandler.WARN); - } - break; - case 'S' : ++i; - if (i < args.length) { - result.getOperationList().addFile(args[i]); - } else { - String err = "need arg after -s " + syntax; - ErrHandler.handleErr(err, ErrHandler.WARN); - } - break; - default: - String err = "unrecognized flag : " + arg + syntax; - ErrHandler.handleErr(err, ErrHandler.WARN); - break; - } - } else if (null != result) { - ErrHandler.handleErr("unexpected arg " + arg + syntax, ErrHandler.WARN); - break; - } else { // unflagged argument, need file - should be input file - File _file = new File(arg); - if (_file.exists() && _file.canRead()) { - result.setFile(_file); - } - } - } // reading args - } // have args - return result; - } // init - - // ---------------------------------------------- instance fields - /** ignore case by converting lines to upper case */ - protected boolean ignoreCase = false; - /** collapse internal whitespace by converting to space character */ - protected boolean collapseWhitespace = true; - /** trim leading and trailing whitespace from lines before comparison */ - protected boolean trimWhitespace = false; - /** replace input per replace operations */ - protected boolean replace = false; - /** operations to process the file with */ - protected OperationList operations; - /** handler for our errors*/ - protected ErrHandler handler = ErrHandler.DEFAULT; - /** the File to use */ - protected File file = null; - - // ---------------------------------------------- constructors - /** no getter/setters yet, so construct using - * static RegexpFilter init(String[],RegexpFilter) - */ - protected RegexpFilter() { } - - // ---------------------------------------------- instance methods - - - /** - * Set a file for this RegexpFilter. - * This makes command-line initialization easier. - * @param file the File to set for this RegexpFilter - */ - public void setFile(File file) { this.file = file; } - - /** - * Return file this RegexpFilter was initialized with. - * @return the File this RegexpFilter was initialized with (may be null). - */ - public File getFile() { return file; } - - /** - * Lazy construction of operations list - */ - protected OperationList getOperationList() { - if (null == operations) { - operations = new OperationList(); - replace = true; - } - return operations; - } - - /** - * Process line, applying case and whitespace operations - * before delegating to replace. - * @param string the String to proces - * @return the String as processed - */ - protected String process(String string) { - String label = "process(\"" + string + "\")"; - D.log(label); - if (null == string) return null; - String result = string; - if (ignoreCase) { - result = result.toUpperCase(); - } - if (trimWhitespace) { - result = result.trim(); - } - if (collapseWhitespace) { - final StringBuffer collapse = new StringBuffer(); - StringTokenizer tokens = new StringTokenizer(result); - boolean hasMoreTokens = tokens.hasMoreTokens(); - while (hasMoreTokens) { - collapse.append(tokens.nextToken()); - hasMoreTokens = tokens.hasMoreTokens(); - if (hasMoreTokens) { - collapse.append(" "); - } - } - result = collapse.toString(); - } - if (replace) { - result = getOperationList().replace(result); - D.log(label + " result " + result); - } - return result; - } - - /** - * container for ReplaceOperations constructs on add, - * runs operations against input. - */ - class OperationList { - final ArrayList list; - public OperationList() { - list = new ArrayList(); - } - - /** - * Run input through all the operations in this list - * and return the result. - * @param input the String to process - * @return the String result of running input through all replace - * operations in order. - */ - public String replace(String input) { - if (null == input) return null; - Iterator operations = operations(); - while (operations.hasNext()) { - ReplaceOperation operation = (ReplaceOperation) operations.next(); - input = operation.replace(input); - } - return input; - } - - /** - * Add operations read from file, one per line, - * ignoring empty lines and # or // comments. - * ';' delimits operations within a line as it does - * for addOperation(String), so you must \ escape ; - * in the search or replace segments - */ - public void addFile(String path) { - if (null == path) { - handler.handle("null path", ErrHandler.ABORT); - } else { - File file = new File(path); - if (!file.exists() && file.canRead()) { - handler.handle("invalid path: " + path, ErrHandler.ABORT); - } else { - BufferedReader reader = null; - int lineNumber = 0; - String line = null; - try { - reader = new BufferedReader(new FileReader(file)); - while (null != (line = reader.readLine())) { - lineNumber++; - int loc = line.indexOf("#"); - if (-1 != loc) { - line = line.substring(0,loc); - } - loc = line.indexOf("//"); - if (-1 != loc) { - line = line.substring(0,loc); - } - line = line.trim(); - if (1 > line.length()) continue; - addOperation(line); - } - } catch (IOException e) { - String message ="Error processing file " + path - + " at line " + lineNumber + ": \"" + line + "\"" - + ": " + e.getClass().getName() + ": " + e.getMessage() ; - handler.handle(message, ErrHandler.ABORT); - } finally { - try { - if (reader != null) reader.close(); - } catch (IOException e) { - // ignore - } - } - } - } - } - - /** - * Add operation to list, emitting warning and returning false if not created. - * Add multiple operations at once by separating with ';' - * (so any ; in search or replace must be escaped). - * @param operation a String acceptable to - * ReplaceOperation.makeReplaceOperation(String, ErrHandler), - * of the form sX{search}X{replace}X{g};.. - * @return false if not all added. - */ - public boolean addOperation(String operation) { - StringTokenizer st = new StringTokenizer(operation, ";", false); - String last = null; - ReplaceOperation toAdd; - boolean allAdded = true; - while (st.hasMoreTokens()) { - // grab tokens, accumulating if \ escapes ; delimiter - String next = st.nextToken(); - if (next.endsWith("\\") && (st.hasMoreTokens())) { - next = next.substring(0, next.length()-1); - last = (last == null ? next : last + next); - continue; - } - if (null != last) { - next = last + next; - last = null; - } - toAdd = ReplaceOperation.makeReplaceOperation(next, handler); - if (null != toAdd) { - list.add(toAdd); - } else { - String label = "RegexpFilter.OperationList.addOperation(\"" + operation + "\"): "; - handler.handle(label + " input not accepted " , ErrHandler.WARN); - if (allAdded) allAdded = false; - } - } - return allAdded; - } - - /** - * @return an Iterator over the list of ReplaceOperation - */ - public Iterator operations() { - return list.iterator(); - } - } // class OperationList -} // class RegexpFilter - -/** - * Encapsulate a search/replace operation which uses a RegExp. - */ -class ReplaceOperation { - /** - * This accepts a sed-like substitute command, except that - * the delimiter character may not be used anywhere in the - * search or replace strings, even if escaped. You may use - * any delimiter character. - * Note that although g (replace-globally) is supported as input, - * it is ignored in this implementation. - * @param operation a String of the form sX{search}X{replace}X{g} - */ - public static ReplaceOperation makeReplaceOperation(String operation, ErrHandler handler) { - ReplaceOperation result = null; - StringBuffer err = (null == handler ? null : new StringBuffer()); - final String syntax = "sX{search}X{replace}X{g}"; - // todo: use Point p = isValidOperation(operation); - if (null == operation) { - if (null != err) err.append("null operation"); - } else if (5 > operation.length()) { - if (null != err) err.append("empty operation"); - } else if (!operation.startsWith("s")) { - if (null != err) err.append("expecting s: " + syntax); - } else { - String sep = operation.substring(1,2); - int mid = operation.indexOf(sep, 2); - if (-1 == mid) { - if (null != handler) err.append("expecting middle \"" + sep + "\": " + syntax); - } else if (mid == 2) { - if (null != handler) err.append("expecting search before middle \"" + sep + "\": " + syntax); - } else { - int end = operation.indexOf(sep, mid+1); - if (-1 == end) { - if (null != handler) err.append("expecting final \"" + sep + "\": " + syntax); - } else { - String search = operation.substring(2,mid); - if (!ReplaceOperation.isValidSearch(search)) { - if (null != handler) err.append("invalid search \"" + search + "\": " + syntax); - } else { - String replace = operation.substring(mid+1,end); - if (!ReplaceOperation.isValidReplace(replace)) { - if (null != handler) err.append("invalid replace \"" + replace + "\": " + syntax); - } else { - result = new ReplaceOperation(search, replace, operation.endsWith("g"), handler); - } - } - } - } - } - if ((0 < err.length()) && (null != handler)) { - err.append(" operation=\"" + operation + "\""); - handler.handle(err.toString(), ErrHandler.HALT); - } - return result; - } - - /** - * Return true if the input string represents a valid search operation - * @param replace the String representing a search expression - */ - protected static boolean isValidSearch(String search) { // todo: too weak to be useful now - return ((null != search) && (0 < search.length())); - } - - /** - * Return Point x=mid, y=end if the input string represents a valid search operation - * @param search the String representing a search expression - protected static Point isValidOperation(String search) { - if (null != search) { - final int length = search.length(); - if (5 < length) { - String sep = search.substring(2,3); - int mid = search.indexOf(sep, 3); - if (3 < mid) { - int end = search.indexOf(sep, mid+1); - if ((end == length-1) - || ((end == length-2) - && search.endsWith("g"))) { - return new Point(mid, end); - } - } - } - } - return null; - } - */ - - /** - * Return true if the input string represents a valid replace operation - * @param replace the String representing a replace expression - */ - protected static boolean isValidReplace(String replace) { // todo: too weak to be useful now - boolean result = (null != replace); - return result; - } // isValidReplace - - // ------------------------------------------------- instance members - /** If true, repeat replace as often as possible (todo: repeat not supported) */ - protected final boolean repeat; - /** search pattern */ - protected final String search; - /** replace pattern */ - protected final String replace; - /** regexp processor */ - protected final Regexp regexp; - /** replace buffer (read-only) */ - protected final char[] replaceBuffer; - /** error handler */ - protected final ErrHandler handler; - - // ------------------------------------------------- constructors - private ReplaceOperation(String search, String replace, boolean repeat, ErrHandler handler) { - this.search = search; - this.replace = replace; - this.replaceBuffer = replace.toCharArray(); - this.repeat = repeat; - this.handler = (null != handler ? handler : ErrHandler.DEFAULT); - this.regexp = RegexpFactory.makeRegexp(); - try { - this.regexp.setPattern(search); - } catch (Exception e) { - this.handler.handle("setting search=" + search, e); - } - } - - - /** - * Return true if the input would be matched by the search string of this ReplaceOperation. - * @param input the String to compare - * @return true if the input would be matched by the search string of this ReplaceOperation - */ - public boolean matches(String input) { - return ((null != input) && regexp.matches(input)); - } // matches - - /** - * Replace any search text in input with replacement text, - * returning input if there is no match. More specifically, - *
  • emit unmatched prefix, if any
  • - *
  • emit replacement text as-is, except that - * \[0-9] in the replacement text is replaced - * with the matching subsection of the input text
  • - *
  • emit unmatched suffix, if any
  • - * @param input the String to search and replace - * @throws IllegalArgumentException if null == input - */ - public String replace(String input) { - if (null == input) throw new IllegalArgumentException("null input"); - String label = "replace(\"" + input + "\") "; - D.log(label); - if (matches(input)) { - StringBuffer buffer = new StringBuffer(); - final int length = replaceBuffer.length; - Vector groups = regexp.getGroups(input); - if ((null == groups) || (1 > groups.size())) { - handler.handle(label + "matched but no groups? "); - return input; - } - buffer.setLength(0); - // group 0 is whole; if not same as input, print prefix/suffix - String matchedPart = (String) groups.elementAt(0); - final int matchStart = input.indexOf(matchedPart); - final int matchEnd = matchStart + matchedPart.length(); - if (0 < matchStart) { - buffer.append(input.substring(0, matchStart)); - } - // true if \ escaping special char, esp. replace \[0-9] - boolean specialChar = false; - for (int i = 0; i < length; i++) { - char c = replaceBuffer[i]; - if (specialChar) { - int value = Character.digit(c, 10); // only 0-9 supported - if ((0 <= value) && (value < groups.size())) { - buffer.append((String) groups.elementAt(value)); - } else { - buffer.append(c); - } - specialChar = false; - } else if ('\\' != c) { - D.log("." + c); - buffer.append(c); - } else { - specialChar = true; - } - } - if (specialChar) { - handler.handle(label + "\\ without register: " + replace, - ErrHandler.ABORT); - } - if (matchEnd < input.length()) { - buffer.append(input.substring(matchEnd)); - } - input = buffer.toString(); - } - return input; - } // replace -} // class ReplaceOperation - diff --git a/aspectj-attic/testing-src/org/aspectj/testing/compare/RegexpFilterReader.java b/aspectj-attic/testing-src/org/aspectj/testing/compare/RegexpFilterReader.java deleted file mode 100644 index 5021a5efe..000000000 --- a/aspectj-attic/testing-src/org/aspectj/testing/compare/RegexpFilterReader.java +++ /dev/null @@ -1,291 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 1999-2001 Xerox Corporation, - * 2002 Palo Alto Research Center, Incorporated (PARC). - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Common Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * Xerox/PARC initial implementation - * ******************************************************************/ - - -package org.aspectj.testing.compare; - - -import org.aspectj.testing.util.StringVisitor; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.io.PrintStream; -import java.io.Reader; -import java.util.Vector; - -/** - * Adapt Writer to StringVisitor, with pre- and post-write - * methods for subclasses to override. - */ -class StringDumper implements StringVisitor { - /** subclasses should write errors here and be silent if null */ - protected PrintStream errSink; - private final boolean appendNewlines; - private final BufferedWriter writer; - /** true only if writer non-null and close() was invoked */ - private boolean closed; - - /** - * @param writer the Writer to write to - ignored if null - * @param appendNewLines if true, append newlines after writing - */ - public StringDumper(BufferedWriter writer, boolean appendNewlines) { - this.appendNewlines = appendNewlines; - this.writer = writer; - // closed = false; - errSink = System.err; - } - - /** - * Set error sink - may be null to ignore IOExceptions. - * @param err the PrintStream to use for errors (silent if null) - */ - public void setErrorSink(PrintStream err) { - errSink = err; - } - - /** - * Invoked before the String is written. - * This implementation does nothing. - * @param string the String to be written - * @return false if writing should abort - */ - protected boolean preWrite(String string) - throws IOException { - return true; - } - - /** - * Implement StringVisitor.accept(String) - * by doing preWrite(String), process(String), - * writer.write(String...), and postWrite(String), - * any one of which may result in a false return value. - * @throws Error if invoked after close() - */ - public final boolean accept(String string) { - if (closed) { - String m = "did close() before accept(\"" + string + "\")"; - throw new Error(m); - } - if (null == writer) return false; - try { - if (!preWrite(string)) return false; - string = process(string); - if (null == string) return false; - if (null != writer) writer.write(string, 0, string.length()); - if (!postWrite(string)) return false; - } catch (IOException e) { - PrintStream sink = errSink; - if (null != sink) e.printStackTrace(sink); - return false; - } - return true; - } - - /** - * Transform the input before writing. - * This implementation returns the input. - * @param string the String to transform - * @return the String as changed - if null, - * then halt and return false from the accept method. - */ - protected String process(String string) { - return string; - } - - /** - * Invoked after the String is written. - * This implementation handles writing of the newline. - * @param string the String that was written - * @return false if writing should abort - */ - protected boolean postWrite(String string) - throws IOException { - if (appendNewlines && null != writer) { - writer.newLine(); - } - return true; - } - - /** convenience method to close adopted writer */ - public void close() throws IOException { - if (null != writer) { - writer.close(); - closed = true; - } - } -} -class FilteredDumper extends StringDumper { - protected final RegexpFilter filter; - public FilteredDumper(BufferedWriter writer, - boolean appendNewlines, - RegexpFilter filter) { - super(writer, appendNewlines); - this.filter = filter; - } - public String process(String arg) { - return filter.process(arg); - } -} - -class FilteredAccumulator extends FilteredDumper { - protected final Vector results; - public FilteredAccumulator(RegexpFilter filter) { - super(null, false, filter); - results = new Vector(); - } - public String process(String arg) { - arg = super.process(arg); - synchronized (results) { - results.add(arg); - } - return arg; - } - public Vector getResults() { - synchronized (results) { - return (Vector) results.clone(); - } - } -} - -/** - -/** - * Input file, using a RegexpFilter to preprocess each line. - *
  • read line using superclass LineNumberReader.readLine()
  • - *
  • Preprocess with case and white space operations
  • - *
  • run all the replace operations on the input, in order
  • - *
  • return the line.
  • - * Using anything but the readLine() method will circumvent - * the regular expression replacement processing. - */ -public class RegexpFilterReader extends BufferedReader { - - // ---------------------------------------------- static methods - - /** - * Pass lines from BufferedReader to visitor. - * Stop reading lines if visitor returns false. - * @param input the BufferedReader with the input - * - if null, use System.in - * @param visitor the StringVisitor to pass each line - * if null, just read in all lines and ignore - */ - public static void visitLines(BufferedReader input, - StringVisitor visitor) - throws IOException { - final boolean openInput = (null == input); - if (openInput) input = new BufferedReader(new InputStreamReader(System.in)); - try { - String line = null; - if (null == visitor) { - while (null != (line = input.readLine())) { - // read and ignore - } - } else { - while (null != (line = input.readLine())) { - if (!visitor.accept(line)) { - break; - } - } - } - } finally { - if (openInput && (null != input)) { - try { input.close(); } // todo: ok to close since System.in underlies? - catch (IOException e) { - e.printStackTrace(System.err); - } - } - } - } // visitLines - - // todo move write(in,out) to a utility class - /** - * Convenience method to write one file to another by line. - * Neither input nor output are closed. - * @param input the BufferedReader with the input - if null, use System.in - * @param output the BufferedWriter for the output - if null, use System.out - */ - public static void write(BufferedReader input, - BufferedWriter output) - throws IOException { - final boolean openOutput = (null == output); - if (openOutput) output = new BufferedWriter(new OutputStreamWriter(System.out)); - StringDumper visitor = new StringDumper(output, true); - try { - RegexpFilterReader.visitLines(input, visitor); - } finally { - if (openOutput && (null != visitor)) { - try { visitor.close(); } // todo: ok to close since System.out underlies? - catch (IOException e) { - e.printStackTrace(System.err); - } - } - } - } // write - - /** - * Process file (or System.in) like sed. - * @param args the String[] containing RegexpFilter arguments - */ - public static void main(String[] args) throws IOException { - RegexpFilter filter = RegexpFilter.init(args, null); - if (null != filter) { - File file = filter.getFile(); - Reader reader = null; - if (file != null) { - reader = new FileReader(file); - } else { - reader = new InputStreamReader(System.in); - } - RegexpFilterReader me = new RegexpFilterReader(reader); - me.setFilter(filter); - RegexpFilterReader.write(me, null); - } - } - - // ---------------------------------------------- constructors - public RegexpFilterReader(Reader reader) { - super(reader); - } - public RegexpFilterReader(Reader reader, int size) { - super(reader, size); - } - - // ---------------------------------------------- instance fields - protected RegexpFilter filter; - // ---------------------------------------------- instance methods - public void setFilter(RegexpFilter filter) { - this.filter = filter; - } - - /** - * Process each line as it is read in by the superclass. - */ - public String readLine() throws IOException { - RegexpFilter filter = this.filter; - String line = super.readLine(); - if (null != filter) { - line = filter.process(line); - } - return line; - } - -} // class RegexpFilterReader - - diff --git a/aspectj-attic/testing-src/org/aspectj/testing/compare/TreeCompare.java b/aspectj-attic/testing-src/org/aspectj/testing/compare/TreeCompare.java deleted file mode 100644 index cbf92daf5..000000000 --- a/aspectj-attic/testing-src/org/aspectj/testing/compare/TreeCompare.java +++ /dev/null @@ -1,217 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 1999-2001 Xerox Corporation, - * 2002 Palo Alto Research Center, Incorporated (PARC). - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Common Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * Xerox/PARC initial implementation - * ******************************************************************/ - -package org.aspectj.testing.compare; -import org.aspectj.testing.compare.adapters.StructureGenericTreeNodeFactory; -import org.aspectj.testing.compare.adapters.JTreeNodeGenericTreeNodeFactory; -import org.aspectj.testing.compare.adapters.GenericTreeNodeFactoryI; -// target -// XXX compiler import org.aspectj.asm.StructureNode; -// testing -import javax.swing.tree.TreeNode; -import javax.swing.tree.DefaultMutableTreeNode; -// utils -import java.io.*; - -/** - * Compare two generic trees for tree-equality. - * Currently does not indicate where or how they failed. - * Input trees are serialized to disk in a format that - * is (or can be wrapped using) GenericTreeNode. - * requires files expected.ser and actual.ser - * to deserialize to type StructureNode (untested - use Structure) - * or Swing TreeNode. - */ -public class TreeCompare { - public static boolean DODIFF; - /** - * @param args ignored - reading expected.ser and actual.ser - */ - public static void main(String[] args) { - TreeCompare me = new TreeCompare(); - File expected = new File("expected.ser"); - File actual = new File("actual.ser"); - if ((args.length > 0) - || (!expected.exists() || (!actual.exists()))) { - DODIFF = (args.length > 1); - takeSnapshot(expected); - takeSnapshot(actual); - } - me.compareSnapshots(expected, actual); - } - private static void takeSnapshot(File file) { - DefaultMutableTreeNode snapshot = getRoot(file) ; - ObjectOutputStream p = null; - FileOutputStream ostream = null; - try { - ostream = new FileOutputStream(file); - p = new ObjectOutputStream(ostream); - p.writeObject(snapshot); - } catch (IOException e) { - e.printStackTrace(System.err); - } finally { - try { - if (null != p) p.flush(); - if (null != ostream) ostream.close(); - } catch (IOException o) {} // ignored - } - } - - private static DefaultMutableTreeNode getRoot(File file) { - boolean isActual = (!DODIFF ? false : (-1 != (file.getPath().indexOf("actual")))); - DefaultMutableTreeNode root = new DefaultMutableTreeNode("Edna"); - DefaultMutableTreeNode child = new DefaultMutableTreeNode("Evalyn"); - root.add(child); - child.add(new DefaultMutableTreeNode("Marsha")); - child.add(new DefaultMutableTreeNode("Ray")); - if (DODIFF && isActual) { // Bill added to actual - child.add(new DefaultMutableTreeNode("Bill")); - } - child = new DefaultMutableTreeNode("Clifford"); - root.add(child); - child.add(new DefaultMutableTreeNode("Terry")); - if (DODIFF && isActual) { // Peter mispelled in actual - child.add(new DefaultMutableTreeNode("peter")); - } else { - child.add(new DefaultMutableTreeNode("Peter")); - } - child.add(new DefaultMutableTreeNode("Mary")); - child = new DefaultMutableTreeNode("Anastasia"); - root.add(child); - child.add(new DefaultMutableTreeNode("Victor")); - child.add(new DefaultMutableTreeNode("Valerie")); - child.add(new DefaultMutableTreeNode("Valentine")); - if (DODIFF && isActual) { // Vim added in actual, with a child - DefaultMutableTreeNode par = new DefaultMutableTreeNode("VimAdded"); - par.add(new DefaultMutableTreeNode("Vim kid")); - child.add(par); - } - return root; - } - - /** - * Compare two File by reading in as serialized - * and selecting the appropriate wrappers for the resulting - * Object. - */ - public void compareSnapshots(File expected, File actual) { - try { - // construct the respective trees - FileInputStream efStream = new FileInputStream(expected); - ObjectInputStream eStream = new ObjectInputStream(efStream); - FileInputStream afStream = new FileInputStream(actual); - ObjectInputStream aStream = new ObjectInputStream(afStream); - Object expectedObject = eStream.readObject(); - Object actualObject = aStream.readObject(); - Class expectedObjectClass = (null == expectedObject ? null : expectedObject.getClass()); - Class actualObjectClass = (null == actualObject ? null : actualObject.getClass()); - // todo yuck: switch by type using known factories -// XXX compiler -// if (StructureNode.class.isAssignableFrom(expectedObjectClass)) { -// if (StructureNode.class.isAssignableFrom(actualObjectClass)) { -// compareSnapshots((StructureNode) expectedObject,(StructureNode) actualObject); -// System.err.println("ok"); -// } else { -// signalDifferentTypes(expectedObject, actualObject); -// } -// } else if (DefaultMutableTreeNode.class.isAssignableFrom(expectedObjectClass)) { -// if (DefaultMutableTreeNode.class.isAssignableFrom(actualObjectClass)) { -// compareSnapshots((DefaultMutableTreeNode) expectedObject, -// (DefaultMutableTreeNode) actualObject); -// } else { -// signalDifferentTypes(expectedObject, actualObject); -// } -// } else { - System.err.println("Unrecognized objects - expected: " - + expectedObject + " actual: " + actualObject); -// } - } catch (Throwable t) { - System.err.println("TEST FAILED: " + t.getMessage()); - t.printStackTrace(System.err); - return; - } - } // compareSnapshots(File, File) - - public void signalDifferentTypes(Object lhs, Object rhs) { - Class lhc = lhs.getClass(); - Class rhc = rhs.getClass(); - String err = "Different Types? lhs: " + lhc + "=" + lhs - + " rhs: " + rhc + "=" + rhs; - throw new Error(err); - } - - /** - * Compare two StructureNode by wrapping in GenericTreeNode - */ -// XXX compiler -// public void compareSnapshots(StructureNode expected, StructureNode actual) { -// try { -// GenericTreeNodeFactoryI factory = -// StructureGenericTreeNodeFactory.SINGLETON; -// // this is the custom part: adapter generating generic model -// GenericTreeNode expectRoot -// = factory.createGenericTreeNode(expected, null); -// GenericTreeNode actualRoot -// = factory.createGenericTreeNode(actual, null); -// if (null == actualRoot) System.err.println("null actualRoot"); -// if (null == expectRoot) System.err.println("null expectRoot"); -// compareSnapshots(expectRoot, actualRoot); -// } catch (Throwable t) { -// System.err.println("TEST FAILED: " + t.getMessage()); -// t.printStackTrace(System.err); -// return; -// } -// } // compareSnapshots(TreeModel, TreeModel) - - /** - * Compare two Swing TreeModel by wrapping in GenericTreeNode - */ - public void compareSnapshots(TreeNode expected, TreeNode actual) { - try { - GenericTreeNodeFactoryI factory = - JTreeNodeGenericTreeNodeFactory.SINGLETON; - // this is the custom part: adapter generating generic model - GenericTreeNode expectRoot - = factory.createGenericTreeNode(expected, null); - GenericTreeNode actualRoot - = factory.createGenericTreeNode(actual, null); - if (null == actualRoot) System.err.println("null actualRoot"); - if (null == expectRoot) System.err.println("null expectRoot"); - compareSnapshots(expectRoot, actualRoot); - } catch (Throwable t) { - System.err.println("TEST FAILED: " + t.getMessage()); - t.printStackTrace(System.err); - return; - } - } // compareSnapshots(TreeModel, TreeModel) - - /** Compare GenericTreeNode trees exactly, printing errors */ - public void compareSnapshots(GenericTreeNode expected, GenericTreeNode actual) { - try { - //GenericTreeNodesVisitorI visitor = GenericTreeNode.PRINTALL; - GenericTreeNodesVisitorI visitor = GenericTreeNode.PRINTERR; - //GenericTreeNodesVisitorI visitor = GenericTreeNode.EXACT; - - if (GenericTreeNode.traverse(expected, actual, null, visitor)) { - System.err.println("TEST PASSED"); - } else { - System.err.println("TEST FAILED"); - } - } catch (Throwable t) { - System.err.println("TEST FAILED: " + t.getMessage()); - t.printStackTrace(System.err); - return; - } - } // compareSnapshots(GenericTreeNode, GenericTreeNode) -} // TreeCompare - diff --git a/aspectj-attic/testing-src/org/aspectj/testing/compare/adapters/GenericTreeNodeFactoryI.java b/aspectj-attic/testing-src/org/aspectj/testing/compare/adapters/GenericTreeNodeFactoryI.java deleted file mode 100644 index adee3d3ee..000000000 --- a/aspectj-attic/testing-src/org/aspectj/testing/compare/adapters/GenericTreeNodeFactoryI.java +++ /dev/null @@ -1,33 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 1999-2001 Xerox Corporation, - * 2002 Palo Alto Research Center, Incorporated (PARC). - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Common Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * Xerox/PARC initial implementation - * ******************************************************************/ - -package org.aspectj.testing.compare.adapters; - -import org.aspectj.testing.compare.GenericTreeNode; -/** - * Encapsulate the implementation of an factory to create - * a GenericTreeNode tree from a given input type, to permit - * a general, pluggable factory to operate based on source type. - */ -public interface GenericTreeNodeFactoryI { - /** @return the expected Class of the root node supported by this factory */ - public Class getRootClass(); - - /** - * Create a wrapped generic tree with the input root tree as delegates. - * @param root the {rootClass} root of the tree to convert - never null - * @throws IllegalArgumentException if root is null or not assignable to rootClass - */ - public GenericTreeNode createGenericTreeNode(Object root, GenericTreeNode parent); -} - diff --git a/aspectj-attic/testing-src/org/aspectj/testing/compare/adapters/JTreeNodeGenericTreeNodeFactory.java b/aspectj-attic/testing-src/org/aspectj/testing/compare/adapters/JTreeNodeGenericTreeNodeFactory.java deleted file mode 100644 index 5f48eef40..000000000 --- a/aspectj-attic/testing-src/org/aspectj/testing/compare/adapters/JTreeNodeGenericTreeNodeFactory.java +++ /dev/null @@ -1,102 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 1999-2001 Xerox Corporation, - * 2002 Palo Alto Research Center, Incorporated (PARC). - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Common Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * Xerox/PARC initial implementation - * ******************************************************************/ - -package org.aspectj.testing.compare.adapters; - -import org.aspectj.testing.compare.GenericTreeNode; -import org.aspectj.testing.compare.*; - -import javax.swing.tree.*; // sample uses TreeModel... -import java.util.*; - -/** - * Factory for adapting Swing TreeNode to GenericTreeNode - */ -public class JTreeNodeGenericTreeNodeFactory implements GenericTreeNodeFactoryI { - public static final GenericTreeNodeFactoryI SINGLETON - = new JTreeNodeGenericTreeNodeFactory(); - private JTreeNodeGenericTreeNodeFactory() {} - public Class getRootClass() { - return TreeNode.class; - } - - /** - * Adapt swing TreeModel to tree rooted at GenericTreeNode - * Only takes the current state of a TreeModel which does not - * change during the construction of the adapter. If the - * TreeModel changes, you can ask the adapter for a newly - * wrapped tree. - * Recursively convert entire tree from root to a wrapped tree - * Note this takes a snapshot of the tree such that changes to - * the TreeModel after the constructor returns are ignored. - * Changes during the constructor produce undetermined results. - * @param root the TreeNode taken as root of a tree to wrap - * @param parent the parent of the resulting GenericTreeNode - * @throws IllegalArgumentException if root is null - * or if children are not instanceof TreeNode. - */ - public GenericTreeNode createGenericTreeNode(Object root, GenericTreeNode parent) { - if (null == root) { - throw new IllegalArgumentException("null root"); - } - if (! (root instanceof TreeNode)) { - throw new IllegalArgumentException("not TreeNode: " + root); - } - TreeNode rootNode = (TreeNode) root; - final int numKids = rootNode.getChildCount(); - ArrayList kids = new ArrayList(numKids); - Enumeration children = rootNode.children(); - Object child; - GenericTreeNode result = new GenericTreeNode(); - for (int i = 0; i < numKids; i++) { - if (! children.hasMoreElements()) { - throw new Error("(! children.hasNext())"); - } - child = children.nextElement(); - if (! (child instanceof TreeNode)) { - throw new Error("! (child instanceof TreeNode)): " + child ); - } - kids.add(createGenericTreeNode((TreeNode) child, result)); - } - //result.init(parent, GenericTreeNode.COMPARATOR, rootNode, kids, null); - result.init(parent, JTreeNodeComparator.SINGLETON, rootNode, kids, null); - return result; - } - - /** Comparator for swing TreeNode todo convert from TreeNode to DefaultMutableTreeNode */ - static class JTreeNodeComparator implements Comparator { - public static Comparator SINGLETON = new JTreeNodeComparator(); - private JTreeNodeComparator () {} - public int compare(Object lhs, Object rhs) { - int result = CompareUtil.compare(lhs, rhs); - if (Integer.MAX_VALUE == result) { - Class lhClass = lhs.getClass() ; - Class rhClass = rhs.getClass() ; - if ((DefaultMutableTreeNode.class.isAssignableFrom(lhClass)) - && (DefaultMutableTreeNode.class.isAssignableFrom(rhClass))) { - DefaultMutableTreeNode lh = (DefaultMutableTreeNode) lhs ; - DefaultMutableTreeNode rh = (DefaultMutableTreeNode) rhs ; - Object lhObject = lh.getUserObject(); - Object rhObject = rh.getUserObject(); - result = CompareUtil.compare(lhs, rhs); - if (Integer.MAX_VALUE == result) { - result = lhObject.toString().compareTo(rhObject.toString()); - } - } else { // urk - broken unless wrapper - result = lhs.toString().compareTo(rhs.toString()); - } - } - return result; - } - } -} diff --git a/aspectj-attic/testing-src/org/aspectj/testing/compare/adapters/Structure.java b/aspectj-attic/testing-src/org/aspectj/testing/compare/adapters/Structure.java deleted file mode 100644 index b669f7c6b..000000000 --- a/aspectj-attic/testing-src/org/aspectj/testing/compare/adapters/Structure.java +++ /dev/null @@ -1,438 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 1999-2001 Xerox Corporation, - * 2002 Palo Alto Research Center, Incorporated (PARC). - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Common Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * Xerox/PARC initial implementation - * ******************************************************************/ - -package org.aspectj.testing.compare.adapters; - -import org.aspectj.testing.compare.GenericTreeNode; -import org.aspectj.testing.compare.GenericTreeNodesVisitorI; -import org.aspectj.testing.compare.GenericTreeNodeListOrdererFactoryI; -import org.aspectj.testing.compare.GenericTreeNodeListOrdererI; -import org.aspectj.testing.compare.adapters.StructureGenericTreeNodeFactory; - -// XXX compiler import org.aspectj.asm.StructureNode; -// XXX wes move to ajde tests import org.aspectj.tools.ajde.StructureUtilities; - -import java.util.*; -import java.io.*; - -/** - * Compare or print (serialized) structure tree/graph(s). - * Mostly thread-safe, except that (todo for now) PRINT_SINK is a mutable static - * variable settable by the arguments. - * See {@link #main(String[]) main} for usage. - */ -public class Structure { - // ---------------------------------- static fields - // PRINT_SINK as static permits static inner class singleton visitors to reflect output sink policy - /** WARNING: print sink changeable at runtime (affects all instances of class!) */ - public static PrintStream PRINT_SINK = System.err; - - /** singleton factory to sort by string */ - protected static final GenericTreeNodeListOrdererFactoryI STRING_SORTER_FACTORY - = new StringSortFactory(); - /** singleton factory to sort by string */ - protected static final GenericTreeNodeListOrdererI STRING_SORTER - = new StringSort(); - /** singleton to sort by string */ - protected static final Comparator STRING_COMP = new StringComparator(); - /** default visitor printer expects only one of pair and render each parent as tab */ - protected static final GenericTreeNodesVisitorI PRINT_EACH = new PrintEach(); - /** visitor printer prints long version of both input (todo: not redirected by toOut) */ - protected static final GenericTreeNodesVisitorI PRINT_ALL = GenericTreeNode.PRINTALL; - /** visitor printer prints long version of both input if non-matching (todo: not redirected by toOut) */ - protected static final GenericTreeNodesVisitorI PRINT_ERR = GenericTreeNode.PRINTERR; - /** parms: default list of files used if no files given */ - public static final String DEFAULT_LST = "default.lst"; - /** parms: default argument list if none given */ - public static final String[] DEFAULT_ARGS = new String[] - { "-d" , "classes" , "-workingdir", "ajworkingdir", "-argfile", DEFAULT_LST}; - - // ---------------------------------- static methods - /** - * Print and/or compare Structure trees. - * One (actual) can be compiled at the same time; - * either (expected or actual) may be read in from a serialized tree. - * Supported arguments: - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
    {ajc compiler args}The set of compiler arguments, to compile a new tree
    -expect {file}.serThe old Structure tree to read in and compare with new
    -actual {file}.serThe new Structure tree to read in (i.e., no compile)
    -save {file}.serSerialize the results of the compile to {file}.ser.
    -printallPrint all pairs in long format
    -printeachPrint each item in short format - * - used when only one tree is available
    -printerrPrint pairs of items that do not match - * - used when only both trees are available
    -sortStringbefore comparing, do a string-sort on each child list.
    -toOutRedirect output from System.err to System.out (for all instances of this class)
    -notestDo not run test (e.g., just compile and save)
    - * @param args the String[] of arguments for this test - defaults supplied if empty. - */ - public static void main(String[] args) { - new Structure().runTest(args); - } - - // ---------------------------------- static util - protected static final void log(String s) { - final PrintStream sink = PRINT_SINK; - if ((null != s) && (null != sink)) { - sink.println("Structure: " + s); - } - } - - protected static void signal(String message) { - log(message); - } - protected static void signal(String context, String event) { - log(context + ": " + event); - } - protected static void signal(String context, Throwable event) { - if (null == event) { - log(context); - } else { - String msg = event.getMessage(); - log(context + ": " + msg); - event.printStackTrace(PRINT_SINK); - } - } - - // ---------------------------------- instance fields - /** args result: path to serialize actual tree to */ - protected String actualSavePath = null; - /** args result: path of actual serialized tree */ - protected String actualPath = null; - /** args result: path of expected serialized tree */ - protected String expectedPath = null; - /** args result: false if not running comparisons */ - protected boolean doComparison = true; - - /** visitor to run - print or test (default is PRINT_ALL) */ - protected GenericTreeNodesVisitorI visitor = PRINT_ALL; - /** this determines for each set of children whether/how to sort them */ - protected GenericTreeNodeListOrdererFactoryI sorter = null; - - // ---------------------------------- instance methods - /** no-arg (default) constructor */ - public Structure() { } - - /** - * Clear settings before running. - * Use this unless you want to inherit settings from - * a prior run. You can specify new arguments that - * overwrite the old settings. - * @param args the String[] used for runTest(String[]) - * @see #clear() - * @see #runTest(String[]) - */ - public synchronized void clearAndRunTest(String[] args) { - actualSavePath = null; - actualPath = null; - expectedPath = null; - doComparison = true; - visitor = PRINT_ALL; - runTest(args); - } - - /** - * Read and/or write and/or compare structure trees. - * Any results are delivered by the comparison visitors. - * The test process is as follows: - *
  • processArgs(..)
  • - *
  • saveActual(..) if saving actual to file
  • - *
  • doComparison(..) of actual and expected per visitor/sorter options
  • - *

    If you run this consecutively, you'll inherit the values - * of the last run that you do not overwrite - * unless you invoke {@link #clear()}. The method synchronization - * will not prevent another thread from interrupting your - * @param args the String[] defined by main(String[] args) - */ - public synchronized void runTest(String[] args) { - if (null == args) throw new IllegalArgumentException("null args"); - args = processArgs(args); - if (null == args) throw new IllegalArgumentException("bad args"); -// XXX compiler -//// StructureNode lhsRoot = loadStructureNode(expectedPath); -//// StructureNode rhsRoot = loadStructureNode(actualPath); -//// if (null == rhsRoot) { // not serialized - try compile -//// // XXX wes move to ajde tests rhsRoot = StructureUtilities.buildStructureModel(args); -//// } -//// // save actual, if requested -//// saveActual(rhsRoot); -//// // do comparison (i.e., run test) -//// doComparison(lhsRoot, rhsRoot); - } - - /** - * Process arguments by extracting our arguments from callee arguments - * and initializing the class accordingly. - * {@link See main(String[])} for a list of valid arguments. - * @param args the String[] adopted, elements shifted down to remove ours - * @return a String[] containing args not relevant to us (i.e., for callee = compiler) - */ - protected String[] processArgs(String[] args) { - if ((null == args) || (1 > args.length)) { - return processArgs(DEFAULT_ARGS); - } - int numFiles = 0; - int numArgFiles = 0; - final String SKIP = "skip"; - String calleeArg; - int readIndex = 0; - int writeIndex = 0; - while (readIndex < args.length) { - final String arg = args[readIndex]; - calleeArg = arg; - // assume valid arg for callee unless shown to be ours - if ((null == arg) || (0 == arg.length())) { - signal("processArgs", "empty arg at index "+ readIndex); - break; - } else if (arg.startsWith("@") || "-argfile".equals(arg)) { - numArgFiles++; - } else if (arg.endsWith(".java")) { - numFiles++; - } else if (arg.startsWith("-")) { - calleeArg = SKIP; // assume args are ours unless found otherwise - if ("-toOut".equals(arg)) { - Structure.PRINT_SINK = System.out; - } else if ("-notest".equals(arg)) { - doComparison = false; - } else if ("-printall".equals(arg)) { - visitor = PRINT_ALL; - } else if ("-printeach".equals(arg)) { - visitor = PRINT_EACH; - } else if ("-printerr".equals(arg)) { - visitor = PRINT_ERR; - } else if ("-sortString".equals(arg)) { - sorter = STRING_SORTER_FACTORY; - } else { // the rest of ours require a parm - readIndex++; - String next = ((readIndex < args.length) - ? args[readIndex] : null); - boolean nextIsOption - = ((null != next) && next.startsWith("-")); - if ("-expect".equals(arg)) { - expectedPath = next; - } else if ("-actual".equals(arg)) { - actualPath = next; - } else if ("-save".equals(arg)) { - actualSavePath = next; - } else { - readIndex--; - calleeArg = arg; // ok, not ours - save - } - if ((calleeArg == SKIP) - && ((null == next) || (nextIsOption))) { - signal("processArgs", arg + " requires a parameter"); - break; - } - } - } - if (SKIP != calleeArg) { - args[writeIndex++] = calleeArg; - } - readIndex++; - } // end of reading args[] - if (readIndex < args.length) { // bad args[] - abort (see signals above) - return null; - } - // if no input specified, supply default list file - if ((0 == numFiles) && (0 == numArgFiles) && (null == actualPath)) { - if (writeIndex+3 > args.length) { - String[] result = new String[writeIndex+2]; - System.arraycopy(args, 0, result, 0, writeIndex); - args = result; - } - args[writeIndex++] = "-argfile"; - args[writeIndex++] = DEFAULT_LST; - } - // if some args clipped (ours), clip array to actual (callee) - if (writeIndex < args.length) { - String[] result = new String[writeIndex]; - System.arraycopy(args, 0, result, 0, writeIndex); - args = result; - } - return args; - } // processArgs(String[]) - -// XXX compiler -// /** -// * Load any StructureNode tree at path, if possible -// * @param path the String path to a serialized StructureNode -// */ -// protected StructureNode loadStructureNode(String path) { -// if (null == path) return null; -// StructureNode result = null; -// try { -// FileInputStream stream = new FileInputStream(path); -// ObjectInputStream ois = new ObjectInputStream(stream); -// Object o = ois.readObject(); -// Class oClass = (null == o ? null : o.getClass()); -// if (StructureNode.class.isAssignableFrom(oClass)) { -// result = (StructureNode) o; -// } else { -// signal("loadStructureNode(\"" + path -// + "\") - wrong type: " + oClass); -// } -// } catch (Throwable t) { -// signal("loadStructureNode(\"" + path + "\")", t); -// } -// return result; -// } -// -// /** -// * Save any StructureNode tree to actualSavePath, if possible -// * @param actual the StructureNode root of the actual tree to save -// * (ignored if null) -// */ -// protected void saveActual(StructureNode actual) { -// if ((null != actual) && (null != actualSavePath)) { -// ObjectOutputStream p = null; -// FileOutputStream ostream = null; -// try { -// ostream = new FileOutputStream(actualSavePath); -// p = new ObjectOutputStream(ostream); -// p.writeObject(actual); -// } catch (Throwable e) { -// signal("saveActual(\"" + actual + "\") -> " -// + actualSavePath, e); -// } finally { -// try { -// if (null != p) p.flush(); -// if (null != ostream) ostream.close(); -// } catch (IOException o) {} // ignored -// } -// } -// } - - /** - * Compare two trees based on the settings for - * the visitor and sorter. All results should be - * delivered by the visitor. - * @param expected the StructureNode actual tree to compare - * @param actual the StructureNode actual tree to compare - */ - // XXX compiler -// protected void doComparison(StructureNode expected, StructureNode actual) { -// if (doComparison) { -// final GenericTreeNodeFactoryI fact = -// StructureGenericTreeNodeFactory.SINGLETON; -// GenericTreeNode lhs = null; -// if (expected != null) { -// lhs = fact.createGenericTreeNode(expected, null); -// } -// GenericTreeNode rhs = null; -// if (actual != null) { -// rhs = fact.createGenericTreeNode(actual, null); -// } -// GenericTreeNode.traverse(lhs, rhs, sorter, visitor); -// } -// } - - /** - * A visitor which prints each to the sink (if any). - * If only one of the pair is not null, - * render it using GenericTreeNode.shortString() - */ - static class PrintEach implements GenericTreeNodesVisitorI { - private PrintEach() {} - public boolean visit(GenericTreeNode lhs,GenericTreeNode rhs) { - PrintStream sink = PRINT_SINK; - if (null != sink) { - if ((lhs != null) && (rhs != null)) { // both - sink.println("[lhs=" + lhs + "] [rhs=" + rhs + "]"); - } else { - GenericTreeNode gtn = (null == lhs ? rhs : lhs); - if (null != gtn) { // one - sink.println(gtn.shortString()); - } - } - } - return true; - } - } // class PrintEach - - static class StringSortFactory implements GenericTreeNodeListOrdererFactoryI { - /** - * Produce the correct orderer for the children of the given GenericTreeNodes - * This always produces the same StringSorter. - * @return GenericTreeNodeListOrdererI for children, or null if none to be used - */ - public GenericTreeNodeListOrdererI produce(GenericTreeNode lhs, GenericTreeNode rhs, - GenericTreeNodesVisitorI visitor) { - return STRING_SORTER; - } - } // class StringSortFactory - - /** - * sort input lists by Comparator Structure.STRING_COMP. - */ - static class StringSort implements GenericTreeNodeListOrdererI { - /** - * Order input lists (not copies) - * using the Comparator Structure.STRING_COMP. - * @param lhs the List representing the left-hand-side - * which contains only GenericTreeNode - * @param rhs the List representing the right-hand-side - * which contains only GenericTreeNode - * @return two lists List[] (0 => lhs, 1 => rhs) - */ - public List[] produceLists(List lhs, List rhs) { - if (null != lhs) Collections.sort(lhs, STRING_COMP); - if (null != rhs) Collections.sort(rhs, STRING_COMP); - List[] result = new List[2]; - result[0] = lhs; - result[1] = rhs; - return result; - } - } // class CompSort - - /** - * Comparator that imposes case-sensitive String order - * based on GenericTreeNode.shortString() if both are - * GenericTreeNode, or toString() otherwise. - * If both are null, considered equal. - * If one is null, the other is considered larger. - */ - static class StringComparator implements Comparator { - public int compare(Object lhs, Object rhs) { - if (null == lhs) { - return (null == rhs ? 0 : -1); - } else if (null == rhs) { - return 1; - } else if ((lhs instanceof GenericTreeNode) - && (rhs instanceof GenericTreeNode)) { - String lhsString = ((GenericTreeNode) lhs).shortString(); - String rhsString = ((GenericTreeNode) rhs).shortString(); - if (null == lhsString) { - return (null == rhsString ? 0 : rhsString.compareTo(lhsString)); - } else { - return lhsString.compareTo(rhsString); - } - } else { - return lhs.toString().compareTo(rhs.toString()); - } - } - } // class StringComparator -} // class Structure - diff --git a/aspectj-attic/testing-src/org/aspectj/testing/compare/adapters/StructureGenericTreeNodeFactory.java b/aspectj-attic/testing-src/org/aspectj/testing/compare/adapters/StructureGenericTreeNodeFactory.java deleted file mode 100644 index 1f5883d2c..000000000 --- a/aspectj-attic/testing-src/org/aspectj/testing/compare/adapters/StructureGenericTreeNodeFactory.java +++ /dev/null @@ -1,308 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 1999-2001 Xerox Corporation, - * 2002 Palo Alto Research Center, Incorporated (PARC). - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Common Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * Xerox/PARC initial implementation - * ******************************************************************/ - -package org.aspectj.testing.compare.adapters; -// -//import org.aspectj.asm.SourceLocation; -import org.aspectj.testing.compare.GenericTreeNode; -//import org.aspectj.testing.compare.*; -//import org.aspectj.asm.StructureNode; -//import org.aspectj.asm.LinkNode; -//import org.aspectj.asm.RelationNode; -//import org.aspectj.asm.Relation; -//import org.aspectj.asm.ProgramElementNode; -//import java.util.*; -// -///** -// * Factory for adapting StructureNode trees to GenericTreeNode -// */ -// XXX compiler -public class StructureGenericTreeNodeFactory implements GenericTreeNodeFactoryI { - public GenericTreeNode createGenericTreeNode(Object root, - GenericTreeNode parent) { - return null; - } - /** - * @see org.aspectj.testing.compare.adapters.GenericTreeNodeFactoryI#getRootClass() - */ - public Class getRootClass() { - return null; - } - -} -// protected static final String[] MODIFIERS = new String[] -// { "strictfp", "abstract", "synchronized", "native", -// "final", "transient", "static", "volatile" }; -// protected static final List MODIFIERS_LIST = Arrays.asList(MODIFIERS); -// protected static final String[] ACCESS = new String[] -// { "private", "protected", "package", "public", "privileged" }; -// protected static final List ACCESS_LIST = Arrays.asList(ACCESS); -// -// /** represent empty list of children (todo: use immutable instead) */ -// public static final List EMPTY_LIST = new ArrayList(); -// public static final GenericTreeNodeFactoryI SINGLETON -// = new StructureGenericTreeNodeFactory(); -// /** delegate of the factory */ -// private static final Comparator NODE_COMPARATOR; -// -// static { -// SubTypeComparator init = new SubTypeComparator(); -// init.addComparator(LinkNode.class, LinkNodeComparator.SINGLETON); -// init.addComparator(RelationNode.class, RelationNodeComparator.SINGLETON); -// init.addComparator(ProgramElementNode.class, ProgramElementNodeComparator.SINGLETON); -// init.addComparator(StructureNode.class, StructureNodeComparator.SINGLETON); -// GenericTreeNodeComparator gtnc = new GenericTreeNodeComparator(init); -// NODE_COMPARATOR = gtnc; -// } -// -// private StructureGenericTreeNodeFactory() {} -// public Class getRootClass() { -// return StructureNode.class; -// } -// -// /** -// * Adapt Structure model to tree rooted at GenericTreeNode. -// * Only takes the current state of a model which does not -// * change during the construction of the adapter. If the -// * model changes, you can ask the adapter for a newly -// * wrapped tree. -// * @param root the TreeNode taken as root of a tree to wrap -// * @param parent the parent of the resulting GenericTreeNode -// * @throws IllegalArgumentException if root is null -// * or if children are not instanceof TreeNode. -// */ -// public GenericTreeNode createGenericTreeNode(Object root, -// GenericTreeNode parent) { -// if (null == root) { -// throw new IllegalArgumentException("null root"); -// } -// if (! (root instanceof StructureNode)) { -// throw new IllegalArgumentException("not StructureNode: " + root); -// } -// GenericTreeNode result = new GenericTreeNode(); -// StructureNode rootNode = (StructureNode) root; -// List kidList = rootNode.getChildren(); -// List kids = EMPTY_LIST; -// // get kids of result -// if (null != kidList) { -// final int numKids = kidList.size(); -// ArrayList newKids = new ArrayList(numKids); -// ListIterator kidIter = kidList.listIterator(); -// Object child; -// for (int i = 0; i < numKids; i++) { -// if (! kidIter.hasNext()) { // items removed from list while iterating -// throw new Error("(! hasNext())"); -// } -// child = kidIter.next(); -// if (! (child instanceof StructureNode)) { -// throw new Error("! (child instanceof StructureNode)): " + child ); -// } -// newKids.add(createGenericTreeNode((StructureNode) child, result)); -// } -// kids = newKids; -// } -// // todo: select comparator here - avoids type checking at run time -// //result.init(parent, StructureComparator.SINGLETON, rootNode, kids, null); -// result.init(parent, NODE_COMPARATOR, rootNode, kids, null); -// return result; -// } -// -// /** Comparator for GenericTreeNode delegates to handler for nodes... */ -// static final class GenericTreeNodeComparator implements Comparator { -// private final Comparator delegate; -// private GenericTreeNodeComparator (Comparator delegate) { -// this.delegate = delegate; -// } -// public final int compare(Object lhs, Object rhs) { -// return delegate.compare(((GenericTreeNode)lhs).getNode() -// , ((GenericTreeNode)lhs).getNode()); -// } -// } -// -// /** -// * Comparator for RelationNode delegates to String & boolean comparison of public attributes. -// */ -// static class RelationNodeComparator implements Comparator { -// public static Comparator SINGLETON = new RelationNodeComparator(); -// private RelationNodeComparator () {} -// /** -// * Comparator for RelationNode uses String & boolean comparison of public attributes -// * forwardNavigationName, backNavigationName, associationName, symmetrical, associative. -// */ -// public int compare(Object lhs, Object rhs) { -// int result = CompareUtil.compare(lhs, rhs); -// if (Integer.MAX_VALUE == result) { -// RelationNode lh = (RelationNode) lhs ; -// RelationNode rh = (RelationNode) rhs ; -// Relation leftRelation = lh.getRelation(); -// Relation rightRelation = rh.getRelation(); -// String left = null; -// String right = null; -// result = CompareUtil.compare(leftRelation, rightRelation); -// if (0 == result) { -// left = leftRelation.getForwardNavigationName(); -// right = rightRelation.getForwardNavigationName(); -// result = CompareUtil.compare(left, right); -// } -// if (0 == result) { -// left = leftRelation.getBackNavigationName(); -// right = rightRelation.getBackNavigationName(); -// result = CompareUtil.compare(left, right); -// } -// if (0 == result) { -// left = leftRelation.getAssociationName(); -// right = rightRelation.getAssociationName(); -// result = CompareUtil.compare(left, right); -// } -// boolean l = false; -// boolean r = false; -// if (0 == result) { -// l = leftRelation.isSymmetrical(); -// r = rightRelation.isSymmetrical(); -// result = CompareUtil.compare(l, r); -// } -// if (0 == result) { -// l = leftRelation.isTransitive(); -// r = rightRelation.isTransitive(); -// result = CompareUtil.compare(l, r); -// } -// } -// return result; -// } -// } -// -// /** Comparator for ProgramElementNode. */ -// static class ProgramElementNodeComparator implements Comparator { -// public static Comparator SINGLETON = new ProgramElementNodeComparator(); -// private ProgramElementNodeComparator () {} -// public int compare(Object lhs, Object rhs) { -// int result = CompareUtil.compare(lhs, rhs); -// if (Integer.MAX_VALUE == result) { -// ProgramElementNode lh = (ProgramElementNode) lhs ; -// ProgramElementNode rh = (ProgramElementNode) rhs ; -// -// boolean rhStmntKind = rh.isCode(); -// boolean lhStmntKind = lh.isCode(); -// if (lhStmntKind != rhStmntKind) { -// return (lhStmntKind ? 1 : -1); -// } -// String left= lh.getKind(); -// String right= rh.getKind(); -// // boilerplate -// result = CompareUtil.compare(left, right); -// if (Integer.MAX_VALUE == result) { -// result = left.compareTo(right); -// if (0 != result) return result; -// } -// right = rh.getSignature(); -// left = lh.getSignature(); -// result = CompareUtil.compare(left, right); -// if (Integer.MAX_VALUE == result) { -// result = left.compareTo(right); -// if (0 != result) return result; -// } -// List rightList = rh.getModifiers(); -// List leftList = lh.getModifiers(); -// result = CompareUtil.compare(leftList, rightList, MODIFIERS_LIST); -// if (0 != result) return result; -// -// result = compare(rh.getAccessibility(), lh.getAccessibility()); -// if (0 != result) return result; -// -// right = rh.getDeclaringType(); -// left = lh.getDeclaringType(); -// result = CompareUtil.compare(left, right); -// if (Integer.MAX_VALUE == result) { -// result = left.compareTo(right); -// if (0 != result) return result; -// } -// -// SourceLocation leftSourceLocation = rh.getSourceLocation(); -// SourceLocation rightSourceLocation = rh.getSourceLocation(); -// int iright= rightSourceLocation.getLineNumber(); -// int ileft= leftSourceLocation.getLineNumber(); -// if (iright != ileft) return (ileft-iright); -// iright= rightSourceLocation.getColumnNumber(); -// ileft= leftSourceLocation.getColumnNumber(); -// if (iright != ileft) return (ileft-iright); -// -// right= rh.getFormalComment(); -// left= lh.getFormalComment(); -// if (Integer.MAX_VALUE == result) { -// result = left.compareTo(right); -// if (0 != result) return result; -// } -// -// right = rh.toString(); // ignored? super -// left = lh.toString(); // ignored? super -// if (Integer.MAX_VALUE == result) { -// result = left.compareTo(right); -// if (0 != result) return result; -// } -// // ignore source file path - may change? -// // lhSourceFilePath = lh.getSourceFilePath(); // ignored -// // lh.sourceFilePath = lh.getSourceFilePath(); // ignored -// // List rhRelations= rh.getRelations() ; // ignored -// // List lhRelations= lh.getRelations(); // ignored -// return 0; -// } -// return result; -// } -// } -// -// /** Comparator for LinkNode. */ -// static class LinkNodeComparator implements Comparator { -// public static Comparator SINGLETON = new LinkNodeComparator(); -// private LinkNodeComparator () {} -// public int compare(Object lhs, Object rhs) { -// int result = CompareUtil.compare(lhs, rhs); -// if (Integer.MAX_VALUE == result) { -// LinkNode lh = (LinkNode) lhs ; -// LinkNode rh = (LinkNode) rhs ; -// // LinkNode only has child and lexical name in toString -// result = lh.toString().compareTo(rh.toString()); -// } -// return result; -// } -// } // class LinkNodeComparator -// -// /** -// * Comparator for StructureNode. -// *

  • todo: implement comparators for each StructureNode subtype
  • -// */ -// static class StructureNodeComparator implements Comparator { -// public static Comparator SINGLETON = new StructureNodeComparator(); -// private StructureNodeComparator () {} -// public int compare(Object lhs, Object rhs) { -// int result = CompareUtil.compare(lhs, rhs); -// if (Integer.MAX_VALUE == result) { -// Class lhClass = lhs.getClass() ; -// Class rhClass = rhs.getClass() ; -// if ((StructureNode.class.isAssignableFrom(lhClass)) -// && (StructureNode.class.isAssignableFrom(rhClass))) { -// StructureNode lh = (StructureNode) lhs ; -// StructureNode rh = (StructureNode) rhs ; -// Object lhObject = lh.getName(); // todo: weak name-based comparison -// Object rhObject = rh.getName(); -// result = CompareUtil.compare(lhs, rhs); -// if (Integer.MAX_VALUE == result) { -// result = lhObject.toString().compareTo(rhObject.toString()); -// } -// } else { // urk - broken unless wrapper -// result = lhs.toString().compareTo(rhs.toString()); -// } -// } -// return result; -// } -// } -//} diff --git a/aspectj-attic/testing-src/org/aspectj/testing/compare/adapters/SubTypeComparator.java b/aspectj-attic/testing-src/org/aspectj/testing/compare/adapters/SubTypeComparator.java deleted file mode 100644 index 3094fdb64..000000000 --- a/aspectj-attic/testing-src/org/aspectj/testing/compare/adapters/SubTypeComparator.java +++ /dev/null @@ -1,224 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 1999-2001 Xerox Corporation, - * 2002 Palo Alto Research Center, Incorporated (PARC). - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Common Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * Xerox/PARC initial implementation - * ******************************************************************/ - -package org.aspectj.testing.compare.adapters; - -import org.aspectj.testing.compare.CompareUtil; -import java.util.Comparator; - -// for testing code -import java.util.*; -import java.text.Collator; - -/** - * This adopts pairs of [Class, Comparator] - * and implements compare by delegation thereto, - * selecting the first added where the classes of the both inputs - * are assignable to the pair Class. - * It first applies the null-semantics of CompareUtil.compare(..), - * which holds that null values are less-than non-null values, - * and that two nulls are equal. - * Note that this class uses Object.equals(..)'s default reference - * equality, so two SubTypeComparator with the same list - * of delegates will NOT be considered equal. - *

    todo: This class is not thread-safe. - *

    todo: immutable: final list copy on construction to implement equals?? - */ -public class SubTypeComparator implements Comparator { - /** order-sensitive comparators collection */ - private Vector comparators; - /** copy of comparators for compare method */ - private Struct[] cache; - - /** default constructor */ - public SubTypeComparator () { - comparators = new Vector(); - } - - /** - * Return true if the Class is in the list of comparators - * as of the initial execution of the method. - * @param c the Class to look for a comparator - * @return true of comparator exists for c - */ - private boolean contains(Class c) { - final int size = comparators.size(); - for (int i = 0; i < size; i++) { - if (c == ((Struct) comparators.elementAt(i)).accepts) { - return true; - } - } - return false; - } - - /** - * Get copy of comparators for compare operation. - */ - private Struct[] getComparators() { // todo: sync on comparators - if ((null == cache) || (cache.length < comparators.size())) { - cache = new Struct[comparators.size()]; - comparators.copyInto(cache); - } - return cache; - } - - /** - * Add a Class, Comparator pair as delegate when - * both input are assignable to Class. - * Note that additions are checked in the order they are added, - * so add the lowest subtypes first. (i.e., if you add - * a comparator for Class Object first, none of the others - * will ever match.) - * @param accepts the Class supertype of objects to accept - * @param comparator the Comparator to use on such objects - * @return false if not added, because either input is null - * or because the Class is represented already. - */ - public final boolean addComparator(Class accepts, Comparator comparator) { - if ((null == accepts) || (null == comparator) - || (contains(accepts))) { - return false; - } - comparators.addElement(new Struct(accepts, comparator)); - return true; - } - - /** - * This implements compare by delegating - * to the first input Comparator - * where the class of the both input - * is assignable to the pair Class. - * It first enforces the null-semantics of CompareUtil.compare(..). - * @throws ClassCastException if both input are not null and - * they are not assignable to any registered Comparator. - */ - public final int compare(Object lhs, Object rhs) { - int result = CompareUtil.compare(lhs, rhs); - if (Integer.MAX_VALUE == result) { - Class lhClass = lhs.getClass() ; - Class rhClass = rhs.getClass() ; - Struct[] comp = getComparators(); - Class compClass; - for (int i = 0; i < comp.length; i++) { - compClass = comp[i].accepts; - if ((compClass.isAssignableFrom(lhClass)) - && (compClass.isAssignableFrom(lhClass))) { - return comp[i].comparator.compare(lhs, rhs); - } - } - // not found - throw ClassCastException - String mssg = "Unable to find Comparator for " - + "lhs Class: " + lhClass.getName() - + " rhs Class: " + rhClass.getName(); - throw new ClassCastException(mssg); - } - return result; - } - - /** - * (unnecessary) Struct to hold class-comparator pair - * is preparation for using collections - */ - static class Struct { - public final Class accepts; - public final Comparator comparator; - /** - * @param accepts the Class to accept input for - not null - * @param comparator the Comparator to compare input with - not null - */ - public Struct(Class accepts,Comparator comparator) { - this.accepts = accepts; - this.comparator = comparator; - } - /** delegate to accept hashcode */ - public int hashCode() { return accepts.hashCode() ; } - /** WARNING: fast comparison based only on accept key reference identity */ - public boolean equals(Object o) { - return ((null != o) && (o instanceof Struct) - && (accepts == ((Struct)o).accepts)); - } - } // class Struct - - //----------------------------------------------- test code - /** test code */ - static class Test { // todo move elsewhere - public void runTest(String[] args) { - if ((null == args) || (1 > args.length)) { - args = new String[] { "one", "two", "THREE", "FOUR", "fIVE", "6" }; - } - SubTypeComparator me = new SubTypeComparator(); - String[] copy = new String[args.length]; - System.arraycopy(args, 0, copy, 0, copy.length); - List list = Arrays.asList(args); - Throwable result = test(me, list); - if ((null == result) - && (!ClassCastException.class.isAssignableFrom(result.getClass()))) { - System.err.println("FAIL: expected cce: " + result); - } - me.addComparator(String.class, Collator.getInstance()); - me.addComparator(Object.class, new Comparator () { - public int compare (Object lhs, Object rhs) { - throw new Error("never used"); - }}); - result = test(me, list); - if (null != result) { - if (ClassCastException.class.isAssignableFrom(result.getClass())) { - System.err.println("FAIL: unexpected cce: " + result); - } else { - System.err.println("FAIL: unexpected Throwable: " + result); - } - } - // heterogeneous - pick Object - Object[] temp = new Object[] { "string", new Integer(1) }; - result = test(me, Arrays.asList(temp)); - if ((null == result) - && (!Error.class.isAssignableFrom(result.getClass()))) { - System.err.println("FAIL: expected Error: " + result); - } - - StringBuffer toPrint = print(Arrays.asList(copy), null); - toPrint.append("\n"); - print(list, toPrint); - System.err.println(toPrint.toString()); - } - - StringBuffer print(List list, StringBuffer sb) { - if (null == sb) sb = new StringBuffer(); - sb.append("["); - ListIterator iter = list.listIterator(); - while (iter.hasNext()) { - sb.append(iter.next().toString()); - if (iter.hasNext()) sb.append(", "); - } - sb.append("]"); - return sb; - } - - /** - * run comparison, return true if got expected exception - */ - Throwable test(Comparator c, List l) { - try { - Collections.sort(l,c); - return null; - } catch (Throwable r) { - return r; - } - } - } // class Test - - /** invoke Test.runTest(args) todo remove */ - public static void main(String[] args) { - new Test().runTest(args); - } -} // class SubTypeComparator diff --git a/aspectj-attic/testing-src/org/aspectj/testing/compare/adapters/package.html b/aspectj-attic/testing-src/org/aspectj/testing/compare/adapters/package.html deleted file mode 100644 index c2d839ed1..000000000 --- a/aspectj-attic/testing-src/org/aspectj/testing/compare/adapters/package.html +++ /dev/null @@ -1,50 +0,0 @@ - - -These adapters facilitate using the GenericTreeNode -comparison utilities on different types of trees. -The classes currently in this package support Swing -TreeNode and AspectJ compiler StructureNode. - -

    -Structure supports a command-line interface for -compiling StructureNode trees using -AspectJCompiler and saving -or loading them using serialization. Once loaded, two trees -can be compared using the GenericTreeNode.traverse(..) method, -providing it the appropriate visitors and comparators to implement -a comparison of the expected and actual structure trees and -report on any differences. (This is used to validate that -changes to the structure tree are backwards compatible with -trees from previous compiles, since the structure tree is -effectively exported from the compiler to the IDE tools.) - -

    -If you want to support new trees, -GenericTreeNodeFactoryI is the interface to implement. -It specifies a factory to provide a Comparator based -on a given pair to be compared. This means that you can -use (or generate) comparators based on specific pairs. -Usually you will implement only for the target type, -so your factory may be final and always return a -singleton Comparator. -

    -The SubTypeComparator implements a Comparator -container that acts as a Comparator by delegating to -contained Comparators registered along with the class of the input -they accept. This permits you to write type-specific -Comparators for heterogeneous trees. It does require -both members of the comparison be assignable to the -target class. - -

    -StructureGenericTreeNodeFactory is an implementation of -GenericTreeNodeFactoryI for StructureNode trees. It -contains comparator classes for RelationNode, LinkNode, -and ProgramElementNode, -combined using a SubTypeComparator. -

    -JTreeNodeGenericTreeNodeFactory is an implementation of -GenericTreeNodeFactoryI for Swing TreeNode's, done only -for testing purposes. - - diff --git a/aspectj-attic/testing-src/org/aspectj/testing/compare/package.html b/aspectj-attic/testing-src/org/aspectj/testing/compare/package.html deleted file mode 100644 index 6bfec163d..000000000 --- a/aspectj-attic/testing-src/org/aspectj/testing/compare/package.html +++ /dev/null @@ -1,128 +0,0 @@ - - -This package implements a general tree comparison as a -special case of visiting generic trees pairwise. -Trees are wrapped as GenericTreeNode, which has a static -method boolean traverse(..) which accepts -a visitor and traverses a pair of trees, calling the -visitor on each. -

    This package supports four forms of generality -through the following classes: - - - - - - - - - - - - - - - -
    ClassesCapability
    GenericTreeNodeAble to handle trees of varying types - by wrapping in a generic form. -
    GenericTreeNodesVisitorI, GenericTreeNode.traverse(..)Can handle any type of pairwise visitor function - by accepting visitor in the traverse method.
    {java.util.Comparator}, GenericTreeNode.getComparator()The object comparison can be sensitive to the type - of the object on a per-object basis, established during - the process of wrapping the tree.
    GenericTreeListOrdererI, GenericTreeListOrdererFactoryIThe ordering of children can be appropriate to - the objective of the traversal. e.g., when computing - "set intersection" rather than "list equals", the - order of children might be changed to align matching - children for the visits. -
    This ordering can be determined as appropriate for each - list comparison by implementing a factory which selects - from the appropriate orderers. Any factory product is used - by the traverse(..) method to order children before - visiting.
    - -

    Supported variants: -The following variants are implemented or planned using the components above: - - - - - - - - - - - - - - - - - - -
    ComponentDescription
    Current
    GenericTreeNode.PRINTALLA visitor which prints out the entire tree.
    GenericTreeNode.PRINTERRA visitor which prints the nonmatching pairs.
    GenericTreeNode.EXACTA visitor which returns false if any pairs do not match.
    TreeCompareA sample program to read in serialized trees and compare them. - (but see Structure in the compare subpackage for a better example)
    CompareUtilMisc comparison utilities (e.g., for short-circuiting comparisons).
    Planned
    GenericTreeNode.KIDDIFFA visitor which calculates tree differences, using ordering children - (catches swaps, missed or added elements, within children)
    GenericTreeNode.TREEDIFFA visitor which calculates tree differences, accumulating the tree - (catches swaps, missed or added elements, throughout tree.)
    - -

    Use: - Run TreeCompare to use the comparer from the command line on a supported tree, - (currently only the Swing TreeNode implemented as DefaultMutableTreeNode). - -

    Programming:
    -To support a new tree, see the Structure example in the compare subpackage -or use example of the Swing TreeNode: -

  • Write an adapter that uses GenericTreeNode to wrap your tree nodes
  • -
  • Write a factory that produces a wrapped tree
  • -
  • Write a Comparator that compares the underlying node object - to include with each node object wrapped. Be sure to implement - the Comparator.equals(Object) method correctly, i.e., returning - true when it is equivalent to another comparator. It is best - to use a singleton for each type of node you support.
  • -
  • Optionally write a visitor to perform whatever operations you wish. - Note that visitors must tolerate a single null input in order to - completely traverse unmatching trees.
  • -
  • To perform operations requiring preprocessing of child List's, - write children orderer(s) and provide a factory to select them.
  • - -

    To design new algorithms/applications, bear in mind the main tools: -

  • The comparator that follows the node object
  • -
  • The visitor that traverses the tree
  • -
  • The child orderer that may preprocess the child lists
  • -
    In particular, when going beyond pair-wise comparisons to - list-wise or tree-wise comparisons, you'll have to decide - where to put the appropriate logic. You may have a relatively - lightweight visitor and a heavyweight orderer, or no - orderer at all. In that case, you may need to invoke a - special method on your visitor after the traversal completes - to do any final processing. - -

    Future Work

    : -

    Smarter group comparisons: -
    Does calculating maps help with diagnosing problems? -

    -Given two lists,
    -  A [ a, b, c, d, e, f, g, h ]
    -  B [ a, e, c, d, b, g, h ]
    -The result should say:
    -  - B swapped order of e and b
    -  - B omitted f
    -Note the match-map (index of matching element, if any):
    -  A->B [ 0, 4, 2, 3, 1, -, 5, 6 ]
    -  B->A [ 0, 4, 2, 3, 1, 6, 7 ]
    -the shift-map (difference between expected and actual order):
    -  A->B [ 0, 3, 0, 0, -3, -, -1, -1 ]
    -  B->A [ 0, 3, 0, 0, -3, 1, 1 ]
    -
    -Thus:
    -- detect swaps as complementary out-of-index order pairs
    -  (todo: three-way or n-ary?)
    -  - fix or ignore swaps
    -- detect shifts as complementary series
    -  where shift-width n is +/- for both
    -  - -n => 
    -    - if negative element is actual, n elements omitted
    -    - if negative element is expected, n elements added
    -
    -
    -
    -
    diff --git a/aspectj-attic/testing-src/org/aspectj/testing/taskdefs/CompareFiles.java b/aspectj-attic/testing-src/org/aspectj/testing/taskdefs/CompareFiles.java
    deleted file mode 100644
    index fe1b760ac..000000000
    --- a/aspectj-attic/testing-src/org/aspectj/testing/taskdefs/CompareFiles.java
    +++ /dev/null
    @@ -1,103 +0,0 @@
    -/* *******************************************************************
    - * Copyright (c) 1999-2001 Xerox Corporation, 
    - *               2002 Palo Alto Research Center, Incorporated (PARC).
    - * All rights reserved. 
    - * This program and the accompanying materials are made available 
    - * under the terms of the Common Public License v1.0 
    - * which accompanies this distribution and is available at 
    - * http://www.eclipse.org/legal/cpl-v10.html 
    - *  
    - * Contributors: 
    - *     Xerox/PARC     initial implementation 
    - * ******************************************************************/
    -
    -
    -package org.aspectj.testing.taskdefs;
    -
    -import java.io.File;
    -import java.io.IOException;
    -import org.apache.tools.ant.*;
    -
    -/**
    - * Wrap file comparison utility as ant taskdef.
    - * (Whitespace semantics track the String.trim() and StringTokenizer class.)
    - * 
    - * 
    - * 
    - * 
    - * 
    - * 
    - * 
    - * 
    - * 
    lhsFilepath to left-hand-side file to compare (required)
    rhsFilepath to right-hand-side file to compare (required)
    outputpath to output file (System.out otherwise)
    ignoreCaseconvert to uppercase before comparison (boolean yes/no)
    trimWhitespaceignore leading/trailing white space(boolean yes/no)
    collapseWhitespaceconvert all white space runs to a single space (boolean yes/no)
    filterSpecall specifications for a filter, based on the RegexpFilter class - * (currently, syntax: {file | {-i|-t|-b|-s |-s }..}
    - * @see org.aspectj.testing.compare.RegexpFilter#init(String[],RegexpFilter) - */ -public class CompareFiles extends org.apache.tools.ant.Task { - /* - Unable to implement multiple inheritance except by delegation: - - Task subclass must be outer or ant throws InstantiationException - - if/since outer, the subclass getter/setters cannot refer to - protected fields in worker superclass absent inner worker - subclass delegate methods. yuck. - - getting access errors when trying to use the RuntimeConfigurable - to initialize the task. Looking at the Ant code, it does not - appear to be used for tasks?? I found none using it and the - initialization seems wrong... - */ - final private Worker worker; - public CompareFiles() { - worker = new Worker(); - } - protected File lhsFile; - protected File rhsFile; - public void setLhsFile(File file) { lhsFile = file; } - public void setRhsFile(File file) { rhsFile = file; } - public void setOutput(File file) { worker.setOutput(file); } - public void setFilterSpec(String str) { worker.setFilterSpec(str); } - public void setCollapseWhitespace(boolean ok) { worker.setCollapseWhitespace(ok); } - public void setTrimWhitespace(boolean ok) { worker.setTrimWhitespace(ok); } - public void setIgnoreCase(boolean ok) { worker.setIgnoreCase(ok); } - public void execute() throws BuildException { - if (!lhsFile.canRead()) { - log("FAIL taskdefs.CompareFiles: bad lhsFile: " + lhsFile); - } else if (!rhsFile.canRead()) { - log("FAIL taskdefs.CompareFiles: bad rhsFile: " + rhsFile); - } else if (rhsFile.isDirectory() != lhsFile.isDirectory()) { - log("FAIL taskdefs.CompareFiles: both must be dirs." - + " lhsFile=" + lhsFile - + " rhsFile=" + rhsFile); - } else { - worker.dodiff(lhsFile, rhsFile); - } - } -} // class CompareFiles - -/** worker class exposes state and converts Exception to BuildException */ -class Worker extends org.aspectj.testing.compare.CompareFiles { - String spec = null; - public void setOutput(File file) { output = file; } - public void setCollapseWhitespace(boolean ok) { collapseWhitespace = ok; } - public void setTrimWhitespace(boolean ok) { trimWhitespace = ok; } - public void setIgnoreCase(boolean ok) { ignoreCase = ok; } - public void setFilterSpec(String str) { spec = str; } - public void initFilter() { - if (null != spec) { - initFilter(spec, false); - } - } - - public void dodiff(File lhsFile, File rhsFile) throws BuildException { - initFilter(); - try { - super.diff(lhsFile, rhsFile); - } catch (IOException t) { - String s = t.getClass().getName() + ": " + t.getMessage(); - throw new BuildException(s, t); - } catch (Throwable e) { - String s = e.getClass().getName() + ": " + e.getMessage(); - throw new BuildException("Error - " + s, e); - } - } -} // class CompareFiles$Worker - diff --git a/aspectj5rt/.classpath b/aspectj5rt/.classpath deleted file mode 100644 index ad9ea7abc..000000000 --- a/aspectj5rt/.classpath +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/aspectj5rt/.cvsignore b/aspectj5rt/.cvsignore deleted file mode 100644 index 38972d828..000000000 --- a/aspectj5rt/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -bin -bintest diff --git a/aspectj5rt/.project b/aspectj5rt/.project deleted file mode 100644 index dcdff0410..000000000 --- a/aspectj5rt/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - aspectj5rt - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/aspectj5rt/.settings/org.eclipse.jdt.core.prefs b/aspectj5rt/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index b42efae28..000000000 --- a/aspectj5rt/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,62 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.builder.cleanOutputFolder=clean -org.eclipse.jdt.core.builder.duplicateResourceTask=warning -org.eclipse.jdt.core.builder.invalidClasspath=ignore -org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch -org.eclipse.jdt.core.circularClasspath=error -org.eclipse.jdt.core.classpath.exclusionPatterns=enabled -org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.doc.comment.support=enabled -org.eclipse.jdt.core.compiler.maxProblemPerUnit=100 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.deprecation=ignore -org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled -org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled -org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore -org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning -org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning -org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning -org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore -org.eclipse.jdt.core.compiler.problem.invalidJavadoc=ignore -org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private -org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore -org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning -org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore -org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=enabled -org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public -org.eclipse.jdt.core.compiler.problem.missingJavadocTags=ignore -org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=enabled -org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=private -org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning -org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning -org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore -org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning -org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore -org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled -org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=ignore -org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore -org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=ignore -org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore -org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore -org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore -org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled -org.eclipse.jdt.core.compiler.problem.unusedImport=warning -org.eclipse.jdt.core.compiler.problem.unusedLocal=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled -org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=ignore -org.eclipse.jdt.core.compiler.source=1.7 -org.eclipse.jdt.core.incompatibleJDKLevel=ignore -org.eclipse.jdt.core.incompleteClasspath=error diff --git a/aspectj5rt/aspectj5rt.mf.txt b/aspectj5rt/aspectj5rt.mf.txt deleted file mode 100644 index dcc05a161..000000000 --- a/aspectj5rt/aspectj5rt.mf.txt +++ /dev/null @@ -1,15 +0,0 @@ -Manifest-Version: 1.0 -Automatic-Module-Name: org.aspectj.runtime - -Name: org/aspectj/lang/ -Specification-Title: AspectJ Runtime Classes -Specification-Version: @build.version.base@ -Specification-Vendor: @company.name@ -Implementation-Title: org.aspectj.tools -Implementation-Version: @build.version@ -Implementation-Vendor: @company.name@ -Bundle-Name: AspectJ Runtime -Bundle-Version: @build.version@ -Bundle-Copyright: (C) Copyright 1999-2001 Xerox Corporation, 2002 Palo - Alto Research Center, Incorporated (PARC), 2003-2009 Contributors. - All Rights Reserved. diff --git a/aspectj5rt/build.xml b/aspectj5rt/build.xml deleted file mode 100644 index a20401a21..000000000 --- a/aspectj5rt/build.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/annotation/ajcDeclareAnnotation.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/annotation/ajcDeclareAnnotation.java deleted file mode 100644 index 5835f3767..000000000 --- a/aspectj5rt/java5-src/org/aspectj/internal/lang/annotation/ajcDeclareAnnotation.java +++ /dev/null @@ -1,25 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.internal.lang.annotation; - -import java.lang.annotation.*; - -/** - * internal representation of declare annotation statement, used by reflect api - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface ajcDeclareAnnotation { - String pattern(); - String annotation(); - String kind(); -} diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/annotation/ajcDeclareEoW.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/annotation/ajcDeclareEoW.java deleted file mode 100644 index e349d603e..000000000 --- a/aspectj5rt/java5-src/org/aspectj/internal/lang/annotation/ajcDeclareEoW.java +++ /dev/null @@ -1,31 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.internal.lang.annotation; - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - - -/** - * @author colyer - * Marker annotation for declare soft declarations - * ajc prefix used to indicate that this annotation is *internal* - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface ajcDeclareEoW { - String message(); - String pointcut(); - boolean isError(); -} diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/annotation/ajcDeclareParents.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/annotation/ajcDeclareParents.java deleted file mode 100644 index 14860e006..000000000 --- a/aspectj5rt/java5-src/org/aspectj/internal/lang/annotation/ajcDeclareParents.java +++ /dev/null @@ -1,31 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.internal.lang.annotation; - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - - -/** - * @author colyer - * Marker annotation for code style declare parent declarations - * ajc prefix used to indicate that this annotation is *internal* - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface ajcDeclareParents { - String targetTypePattern(); - String parentTypes(); - boolean isExtends(); -} diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/annotation/ajcDeclarePrecedence.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/annotation/ajcDeclarePrecedence.java deleted file mode 100644 index ef6197557..000000000 --- a/aspectj5rt/java5-src/org/aspectj/internal/lang/annotation/ajcDeclarePrecedence.java +++ /dev/null @@ -1,32 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.internal.lang.annotation; - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - - -/** - * @author colyer - * Marker annotation for code style declare precedence declarations - * ajc prefix used to indicate that this annotation is *internal* - * Can't use DeclarePrecedence as that has target = type and we - * need method to cope with the (rare) case of multiple declare - * precendence statements in the same aspect. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface ajcDeclarePrecedence { - String value(); -} diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/annotation/ajcDeclareSoft.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/annotation/ajcDeclareSoft.java deleted file mode 100644 index f97de09e2..000000000 --- a/aspectj5rt/java5-src/org/aspectj/internal/lang/annotation/ajcDeclareSoft.java +++ /dev/null @@ -1,30 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.internal.lang.annotation; - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - - -/** - * @author colyer - * Marker annotation for declare soft declarations - * ajc prefix used to indicate that this annotation is *internal* - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface ajcDeclareSoft { - String exceptionType(); - String pointcut(); -} diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/annotation/ajcITD.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/annotation/ajcITD.java deleted file mode 100644 index e67a25f1e..000000000 --- a/aspectj5rt/java5-src/org/aspectj/internal/lang/annotation/ajcITD.java +++ /dev/null @@ -1,31 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.internal.lang.annotation; - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - - -/** - * @author colyer - * Marker annotation for code style ITDs - * ajc prefix used to indicate that this annotation is *internal* - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface ajcITD { - int modifiers(); - String targetType(); - String name(); -} diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/annotation/ajcPrivileged.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/annotation/ajcPrivileged.java deleted file mode 100644 index 78ca43e05..000000000 --- a/aspectj5rt/java5-src/org/aspectj/internal/lang/annotation/ajcPrivileged.java +++ /dev/null @@ -1,27 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.internal.lang.annotation; - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - - -/** - * @author colyer - * Marker annotation for privileged aspects. - * ajc prefix used to indicate that this annotation is *internal* - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface ajcPrivileged {} diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/AdviceImpl.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/AdviceImpl.java deleted file mode 100644 index 77b30223f..000000000 --- a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/AdviceImpl.java +++ /dev/null @@ -1,187 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.internal.lang.reflect; - -import java.lang.reflect.Method; -import java.lang.reflect.Type; - -import org.aspectj.lang.annotation.AdviceName; -import org.aspectj.lang.reflect.Advice; -import org.aspectj.lang.reflect.AdviceKind; -import org.aspectj.lang.reflect.AjType; -import org.aspectj.lang.reflect.AjTypeSystem; -import org.aspectj.lang.reflect.PointcutExpression; - -/** - * @author colyer - * - */ -public class AdviceImpl implements Advice { - - private static final String AJC_INTERNAL = "org.aspectj.runtime.internal"; - - private final AdviceKind kind; - private final Method adviceMethod; - private PointcutExpression pointcutExpression; - private boolean hasExtraParam = false; - private Type[] genericParameterTypes; - private AjType[] parameterTypes; - private AjType[] exceptionTypes; - - protected AdviceImpl(Method method, String pointcut, AdviceKind type) { - this.kind = type; - this.adviceMethod = method; - this.pointcutExpression = new PointcutExpressionImpl(pointcut); - } - - protected AdviceImpl(Method method, String pointcut, AdviceKind type, String extraParamName) { - this(method,pointcut,type); - this.hasExtraParam = true; - } - - public AjType getDeclaringType() { - return AjTypeSystem.getAjType(adviceMethod.getDeclaringClass()); - } - - public Type[] getGenericParameterTypes() { - if (this.genericParameterTypes == null) { - Type[] genTypes = adviceMethod.getGenericParameterTypes(); - int syntheticCount = 0; - for (Type t : genTypes) { - if (t instanceof Class) { - if (((Class)t).getPackage().getName().equals(AJC_INTERNAL)) syntheticCount++; - } - } - this.genericParameterTypes = new Type[genTypes.length - syntheticCount]; - for (int i = 0; i < genericParameterTypes.length; i++) { - if (genTypes[i] instanceof Class) { - this.genericParameterTypes[i] = AjTypeSystem.getAjType((Class)genTypes[i]); - } else { - this.genericParameterTypes[i] = genTypes[i]; - } - } - } - return this.genericParameterTypes; - } - - public AjType[] getParameterTypes() { - if (this.parameterTypes == null) { - Class[] ptypes = adviceMethod.getParameterTypes(); - int syntheticCount = 0; - for(Class c : ptypes) { - if (c.getPackage().getName().equals(AJC_INTERNAL)) syntheticCount++; - } - this.parameterTypes = new AjType[ptypes.length - syntheticCount]; - for (int i = 0; i < parameterTypes.length; i++) { - this.parameterTypes[i] = AjTypeSystem.getAjType(ptypes[i]); - } - } - return this.parameterTypes; - } - - public AjType[] getExceptionTypes() { - if (this.exceptionTypes == null) { - Class[] exTypes = adviceMethod.getExceptionTypes(); - this.exceptionTypes = new AjType[exTypes.length]; - for (int i = 0; i < exTypes.length; i++) { - this.exceptionTypes[i] = AjTypeSystem.getAjType(exTypes[i]); - } - } - return this.exceptionTypes; - } - - public AdviceKind getKind() { - return kind; - } - - public String getName() { - String adviceName = adviceMethod.getName(); - if (adviceName.startsWith("ajc$")) { - adviceName = ""; - AdviceName name = adviceMethod.getAnnotation(AdviceName.class); - if (name != null) adviceName = name.value(); - } - return adviceName; - } - - public PointcutExpression getPointcutExpression() { - return pointcutExpression; - } - - public String toString() { - StringBuffer sb = new StringBuffer(); - if (getName().length() > 0) { - sb.append("@AdviceName(\""); - sb.append(getName()); - sb.append("\") "); - } - if (getKind() == AdviceKind.AROUND) { - sb.append(adviceMethod.getGenericReturnType().toString()); - sb.append(" "); - } - switch(getKind()) { - case AFTER: - sb.append("after("); - break; - case AFTER_RETURNING: - sb.append("after("); - break; - case AFTER_THROWING: - sb.append("after("); - break; - case AROUND: - sb.append("around("); - break; - case BEFORE: - sb.append("before("); - break; - } - AjType[] ptypes = getParameterTypes(); - int len = ptypes.length; - if (hasExtraParam) len--; - for (int i = 0; i < len; i++) { - sb.append(ptypes[i].getName()); - if (i+1 < len) sb.append(","); - } - sb.append(") "); - switch(getKind()) { - case AFTER_RETURNING: - sb.append("returning"); - if (hasExtraParam) { - sb.append("("); - sb.append(ptypes[len-1].getName()); - sb.append(") "); - } - case AFTER_THROWING: - sb.append("throwing"); - if (hasExtraParam) { - sb.append("("); - sb.append(ptypes[len-1].getName()); - sb.append(") "); - } - default: // no-op - } - AjType[] exTypes = getExceptionTypes(); - if (exTypes.length > 0) { - sb.append("throws "); - for (int i = 0; i < exTypes.length; i++) { - sb.append(exTypes[i].getName()); - if (i+1 < exTypes.length) sb.append(","); - } - sb.append(" "); - } - sb.append(": "); - sb.append(getPointcutExpression().asString()); - return sb.toString(); - } - -} diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/AjTypeImpl.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/AjTypeImpl.java deleted file mode 100644 index 5c04def2c..000000000 --- a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/AjTypeImpl.java +++ /dev/null @@ -1,1179 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.internal.lang.reflect; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.lang.reflect.Type; -import java.lang.reflect.TypeVariable; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.EnumSet; -import java.util.List; -import java.util.Set; - -import org.aspectj.internal.lang.annotation.ajcDeclareAnnotation; -import org.aspectj.internal.lang.annotation.ajcDeclareEoW; -import org.aspectj.internal.lang.annotation.ajcDeclareParents; -import org.aspectj.internal.lang.annotation.ajcDeclarePrecedence; -import org.aspectj.internal.lang.annotation.ajcDeclareSoft; -import org.aspectj.internal.lang.annotation.ajcITD; -import org.aspectj.internal.lang.annotation.ajcPrivileged; -import org.aspectj.lang.annotation.After; -import org.aspectj.lang.annotation.AfterReturning; -import org.aspectj.lang.annotation.AfterThrowing; -import org.aspectj.lang.annotation.Around; -import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.annotation.Before; -import org.aspectj.lang.annotation.DeclareError; -import org.aspectj.lang.annotation.DeclareWarning; -import org.aspectj.lang.reflect.Advice; -import org.aspectj.lang.reflect.AdviceKind; -import org.aspectj.lang.reflect.AjType; -import org.aspectj.lang.reflect.AjTypeSystem; -import org.aspectj.lang.reflect.DeclareAnnotation; -import org.aspectj.lang.reflect.DeclareErrorOrWarning; -import org.aspectj.lang.reflect.DeclareParents; -import org.aspectj.lang.reflect.DeclarePrecedence; -import org.aspectj.lang.reflect.DeclareSoft; -import org.aspectj.lang.reflect.InterTypeConstructorDeclaration; -import org.aspectj.lang.reflect.InterTypeFieldDeclaration; -import org.aspectj.lang.reflect.InterTypeMethodDeclaration; -import org.aspectj.lang.reflect.NoSuchAdviceException; -import org.aspectj.lang.reflect.NoSuchPointcutException; -import org.aspectj.lang.reflect.PerClause; -import org.aspectj.lang.reflect.PerClauseKind; -import org.aspectj.lang.reflect.Pointcut; - - -/** - * @author colyer - * - */ -public class AjTypeImpl implements AjType { - - private static final String ajcMagic = "ajc$"; - - private Class clazz; - private Pointcut[] declaredPointcuts = null; - private Pointcut[] pointcuts = null; - private Advice[] declaredAdvice = null; - private Advice[] advice = null; - private InterTypeMethodDeclaration[] declaredITDMethods = null; - private InterTypeMethodDeclaration[] itdMethods = null; - private InterTypeFieldDeclaration[] declaredITDFields = null; - private InterTypeFieldDeclaration[] itdFields = null; - private InterTypeConstructorDeclaration[] itdCons = null; - private InterTypeConstructorDeclaration[] declaredITDCons = null; - - public AjTypeImpl(Class fromClass) { - this.clazz = fromClass; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getName() - */ - public String getName() { - return clazz.getName(); - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getPackage() - */ - public Package getPackage() { - return clazz.getPackage(); - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getInterfaces() - */ - public AjType[] getInterfaces() { - Class[] baseInterfaces = clazz.getInterfaces(); - return toAjTypeArray(baseInterfaces); - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getModifiers() - */ - public int getModifiers() { - return clazz.getModifiers(); - } - - public Class getJavaClass() { - return clazz; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getSupertype() - */ - public AjType getSupertype() { - Class superclass = clazz.getSuperclass(); - return superclass==null ? null : (AjType) new AjTypeImpl(superclass); - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getGenericSupertype() - */ - public Type getGenericSupertype() { - return clazz.getGenericSuperclass(); - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getEnclosingMethod() - */ - public Method getEnclosingMethod() { - return clazz.getEnclosingMethod(); - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getEnclosingConstructor() - */ - public Constructor getEnclosingConstructor() { - return clazz.getEnclosingConstructor(); - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getEnclosingType() - */ - public AjType getEnclosingType() { - Class enc = clazz.getEnclosingClass(); - return enc != null ? new AjTypeImpl(enc) : null; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getDeclaringType() - */ - public AjType getDeclaringType() { - Class dec = clazz.getDeclaringClass(); - return dec != null ? new AjTypeImpl(dec) : null; - } - - public PerClause getPerClause() { - if (isAspect()) { - Aspect aspectAnn = clazz.getAnnotation(Aspect.class); - String perClause = aspectAnn.value(); - if (perClause.equals("")) { - if (getSupertype().isAspect()) { - return getSupertype().getPerClause(); - } - return new PerClauseImpl(PerClauseKind.SINGLETON); - } else if (perClause.startsWith("perthis(")) { - return new PointcutBasedPerClauseImpl(PerClauseKind.PERTHIS,perClause.substring("perthis(".length(),perClause.length() - 1)); - } else if (perClause.startsWith("pertarget(")) { - return new PointcutBasedPerClauseImpl(PerClauseKind.PERTARGET,perClause.substring("pertarget(".length(),perClause.length() - 1)); - } else if (perClause.startsWith("percflow(")) { - return new PointcutBasedPerClauseImpl(PerClauseKind.PERCFLOW,perClause.substring("percflow(".length(),perClause.length() - 1)); - } else if (perClause.startsWith("percflowbelow(")) { - return new PointcutBasedPerClauseImpl(PerClauseKind.PERCFLOWBELOW,perClause.substring("percflowbelow(".length(),perClause.length() - 1)); - } else if (perClause.startsWith("pertypewithin")) { - return new TypePatternBasedPerClauseImpl(PerClauseKind.PERTYPEWITHIN,perClause.substring("pertypewithin(".length(),perClause.length() - 1)); - } else { - throw new IllegalStateException("Per-clause not recognized: " + perClause); - } - } else { - return null; - } - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#isAnnotationPresent(java.lang.Class) - */ - public boolean isAnnotationPresent(Class annotationType) { - return clazz.isAnnotationPresent(annotationType); - } - - public A getAnnotation(Class annotationType) { - return clazz.getAnnotation(annotationType); - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getAnnotations() - */ - public Annotation[] getAnnotations() { - return clazz.getAnnotations(); - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getDeclaredAnnotations() - */ - public Annotation[] getDeclaredAnnotations() { - return clazz.getDeclaredAnnotations(); - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getAspects() - */ - public AjType[] getAjTypes() { - Class[] classes = clazz.getClasses(); - return toAjTypeArray(classes); - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getDeclaredAspects() - */ - public AjType[] getDeclaredAjTypes() { - Class[] classes = clazz.getDeclaredClasses(); - return toAjTypeArray(classes); - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getConstructor(java.lang.Class...) - */ - public Constructor getConstructor(AjType... parameterTypes) throws NoSuchMethodException { - return clazz.getConstructor(toClassArray(parameterTypes)); - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getConstructors() - */ - public Constructor[] getConstructors() { - return clazz.getConstructors(); - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getDeclaredConstructor(java.lang.Class...) - */ - public Constructor getDeclaredConstructor(AjType... parameterTypes) throws NoSuchMethodException { - return clazz.getDeclaredConstructor(toClassArray(parameterTypes)); - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getDeclaredConstructors() - */ - public Constructor[] getDeclaredConstructors() { - return clazz.getDeclaredConstructors(); - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getDeclaredField(java.lang.String) - */ - public Field getDeclaredField(String name) throws NoSuchFieldException { - Field f = clazz.getDeclaredField(name); - if (f.getName().startsWith(ajcMagic)) throw new NoSuchFieldException(name); - return f; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getDeclaredFields() - */ - public Field[] getDeclaredFields() { - Field[] fields = clazz.getDeclaredFields(); - List filteredFields = new ArrayList(); - for (Field field : fields) - if (!field.getName().startsWith(ajcMagic) - && !field.isAnnotationPresent(DeclareWarning.class) - && !field.isAnnotationPresent(DeclareError.class)) { - filteredFields.add(field); - } - Field[] ret = new Field[filteredFields.size()]; - filteredFields.toArray(ret); - return ret; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getField(java.lang.String) - */ - public Field getField(String name) throws NoSuchFieldException { - Field f = clazz.getField(name); - if (f.getName().startsWith(ajcMagic)) throw new NoSuchFieldException(name); - return f; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getFields() - */ - public Field[] getFields() { - Field[] fields = clazz.getFields(); - List filteredFields = new ArrayList(); - for (Field field : fields) - if (!field.getName().startsWith(ajcMagic) - && !field.isAnnotationPresent(DeclareWarning.class) - && !field.isAnnotationPresent(DeclareError.class)) { - filteredFields.add(field); - } - Field[] ret = new Field[filteredFields.size()]; - filteredFields.toArray(ret); - return ret; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getDeclaredMethod(java.lang.String, java.lang.Class...) - */ - public Method getDeclaredMethod(String name, AjType... parameterTypes) throws NoSuchMethodException { - Method m = clazz.getDeclaredMethod(name,toClassArray(parameterTypes)); - if (!isReallyAMethod(m)) throw new NoSuchMethodException(name); - return m; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getMethod(java.lang.String, java.lang.Class...) - */ - public Method getMethod(String name, AjType... parameterTypes) throws NoSuchMethodException { - Method m = clazz.getMethod(name,toClassArray(parameterTypes)); - if (!isReallyAMethod(m)) throw new NoSuchMethodException(name); - return m; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getDeclaredMethods() - */ - public Method[] getDeclaredMethods() { - Method[] methods = clazz.getDeclaredMethods(); - List filteredMethods = new ArrayList(); - for (Method method : methods) { - if (isReallyAMethod(method)) filteredMethods.add(method); - } - Method[] ret = new Method[filteredMethods.size()]; - filteredMethods.toArray(ret); - return ret; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getMethods() - */ - public Method[] getMethods() { - Method[] methods = clazz.getMethods(); - List filteredMethods = new ArrayList(); - for (Method method : methods) { - if (isReallyAMethod(method)) filteredMethods.add(method); - } - Method[] ret = new Method[filteredMethods.size()]; - filteredMethods.toArray(ret); - return ret; - } - - private boolean isReallyAMethod(Method method) { - if (method.getName().startsWith(ajcMagic)) return false; - if (method.getAnnotations().length==0) return true; - if (method.isAnnotationPresent(org.aspectj.lang.annotation.Pointcut.class)) return false; - if (method.isAnnotationPresent(Before.class)) return false; - if (method.isAnnotationPresent(After.class)) return false; - if (method.isAnnotationPresent(AfterReturning.class)) return false; - if (method.isAnnotationPresent(AfterThrowing.class)) return false; - if (method.isAnnotationPresent(Around.class)) return false; - return true; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getDeclaredPointcut(java.lang.String) - */ - public Pointcut getDeclaredPointcut(String name) throws NoSuchPointcutException { - Pointcut[] pcs = getDeclaredPointcuts(); - for (Pointcut pc : pcs) - if (pc.getName().equals(name)) return pc; - throw new NoSuchPointcutException(name); - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getPointcut(java.lang.String) - */ - public Pointcut getPointcut(String name) throws NoSuchPointcutException { - Pointcut[] pcs = getPointcuts(); - for (Pointcut pc : pcs) - if (pc.getName().equals(name)) return pc; - throw new NoSuchPointcutException(name); - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getDeclaredPointcuts() - */ - public Pointcut[] getDeclaredPointcuts() { - if (declaredPointcuts != null) return declaredPointcuts; - List pointcuts = new ArrayList(); - Method[] methods = clazz.getDeclaredMethods(); - for (Method method : methods) { - Pointcut pc = asPointcut(method); - if (pc != null) pointcuts.add(pc); - } - Pointcut[] ret = new Pointcut[pointcuts.size()]; - pointcuts.toArray(ret); - declaredPointcuts = ret; - return ret; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getPointcuts() - */ - public Pointcut[] getPointcuts() { - if (pointcuts != null) return pointcuts; - List pcuts = new ArrayList(); - Method[] methods = clazz.getMethods(); - for (Method method : methods) { - Pointcut pc = asPointcut(method); - if (pc != null) pcuts.add(pc); - } - Pointcut[] ret = new Pointcut[pcuts.size()]; - pcuts.toArray(ret); - pointcuts = ret; - return ret; - } - - private Pointcut asPointcut(Method method) { - org.aspectj.lang.annotation.Pointcut pcAnn = method.getAnnotation(org.aspectj.lang.annotation.Pointcut.class); - if (pcAnn != null) { - String name = method.getName(); - if (name.startsWith(ajcMagic)) { - // extract real name - int nameStart = name.indexOf("$$"); - name = name.substring(nameStart +2,name.length()); - int nextDollar = name.indexOf("$"); - if (nextDollar != -1) name = name.substring(0,nextDollar); - } - return new PointcutImpl(name,pcAnn.value(),method,AjTypeSystem.getAjType(method.getDeclaringClass()),pcAnn.argNames()); - } else { - return null; - } - } - - - public Advice[] getDeclaredAdvice(AdviceKind... ofType) { - Set types; - if (ofType.length == 0) { - types = EnumSet.allOf(AdviceKind.class); - } else { - types = EnumSet.noneOf(AdviceKind.class); - types.addAll(Arrays.asList(ofType)); - } - return getDeclaredAdvice(types); - } - - public Advice[] getAdvice(AdviceKind... ofType) { - Set types; - if (ofType.length == 0) { - types = EnumSet.allOf(AdviceKind.class); - } else { - types = EnumSet.noneOf(AdviceKind.class); - types.addAll(Arrays.asList(ofType)); - } - return getAdvice(types); - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getDeclaredAdvice(org.aspectj.lang.reflect.AdviceType) - */ - private Advice[] getDeclaredAdvice(Set ofAdviceTypes) { - if (declaredAdvice == null) initDeclaredAdvice(); - List adviceList = new ArrayList(); - for (Advice a : declaredAdvice) { - if (ofAdviceTypes.contains(a.getKind())) adviceList.add(a); - } - Advice[] ret = new Advice[adviceList.size()]; - adviceList.toArray(ret); - return ret; - } - - private void initDeclaredAdvice() { - Method[] methods = clazz.getDeclaredMethods(); - List adviceList = new ArrayList(); - for (Method method : methods) { - Advice advice = asAdvice(method); - if (advice != null) adviceList.add(advice); - } - declaredAdvice = new Advice[adviceList.size()]; - adviceList.toArray(declaredAdvice); - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getDeclaredAdvice(org.aspectj.lang.reflect.AdviceType) - */ - private Advice[] getAdvice(Set ofAdviceTypes) { - if (advice == null) initAdvice(); - List adviceList = new ArrayList(); - for (Advice a : advice) { - if (ofAdviceTypes.contains(a.getKind())) adviceList.add(a); - } - Advice[] ret = new Advice[adviceList.size()]; - adviceList.toArray(ret); - return ret; - } - - private void initAdvice() { - Method[] methods = clazz.getMethods(); - List adviceList = new ArrayList(); - for (Method method : methods) { - Advice advice = asAdvice(method); - if (advice != null) adviceList.add(advice); - } - advice = new Advice[adviceList.size()]; - adviceList.toArray(advice); - } - - - public Advice getAdvice(String name) throws NoSuchAdviceException { - if (name.equals("")) throw new IllegalArgumentException("use getAdvice(AdviceType...) instead for un-named advice"); - if (advice == null) initAdvice(); - for (Advice a : advice) { - if (a.getName().equals(name)) return a; - } - throw new NoSuchAdviceException(name); - } - - public Advice getDeclaredAdvice(String name) throws NoSuchAdviceException { - if (name.equals("")) throw new IllegalArgumentException("use getAdvice(AdviceType...) instead for un-named advice"); - if (declaredAdvice == null) initDeclaredAdvice(); - for (Advice a : declaredAdvice) { - if (a.getName().equals(name)) return a; - } - throw new NoSuchAdviceException(name); - } - - private Advice asAdvice(Method method) { - if (method.getAnnotations().length == 0) return null; - Before beforeAnn = method.getAnnotation(Before.class); - if (beforeAnn != null) return new AdviceImpl(method,beforeAnn.value(),AdviceKind.BEFORE); - After afterAnn = method.getAnnotation(After.class); - if (afterAnn != null) return new AdviceImpl(method,afterAnn.value(),AdviceKind.AFTER); - AfterReturning afterReturningAnn = method.getAnnotation(AfterReturning.class); - if (afterReturningAnn != null) { - String pcExpr = afterReturningAnn.pointcut(); - if (pcExpr.equals("")) pcExpr = afterReturningAnn.value(); - return new AdviceImpl(method,pcExpr,AdviceKind.AFTER_RETURNING,afterReturningAnn.returning()); - } - AfterThrowing afterThrowingAnn = method.getAnnotation(AfterThrowing.class); - if (afterThrowingAnn != null) { - String pcExpr = afterThrowingAnn.pointcut(); - if (pcExpr == null) pcExpr = afterThrowingAnn.value(); - return new AdviceImpl(method,pcExpr,AdviceKind.AFTER_THROWING,afterThrowingAnn.throwing()); - } - Around aroundAnn = method.getAnnotation(Around.class); - if (aroundAnn != null) return new AdviceImpl(method,aroundAnn.value(),AdviceKind.AROUND); - return null; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getDeclaredITDMethod(java.lang.String, java.lang.Class, java.lang.Class...) - */ - public InterTypeMethodDeclaration getDeclaredITDMethod(String name, - AjType target, AjType... parameterTypes) throws NoSuchMethodException { - InterTypeMethodDeclaration[] itdms = getDeclaredITDMethods(); - outer: for (InterTypeMethodDeclaration itdm : itdms) { - try { - if (!itdm.getName().equals(name)) continue; - AjType itdTarget = itdm.getTargetType(); - if (itdTarget.equals(target)) { - AjType[] ptypes = itdm.getParameterTypes(); - if (ptypes.length == parameterTypes.length) { - for (int i = 0; i < ptypes.length; i++) { - if (!ptypes[i].equals(parameterTypes[i])) - continue outer; - } - return itdm; - } - } - } catch (ClassNotFoundException cnf) { - // just move on to the next one - } - } - throw new NoSuchMethodException(name); - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getDeclaredITDMethods() - */ - public InterTypeMethodDeclaration[] getDeclaredITDMethods() { - if (this.declaredITDMethods == null) { - List itdms = new ArrayList(); - Method[] baseMethods = clazz.getDeclaredMethods(); - for (Method m : baseMethods) { - if (!m.getName().contains("ajc$interMethodDispatch1$")) continue; - if (m.isAnnotationPresent(ajcITD.class)) { - ajcITD ann = m.getAnnotation(ajcITD.class); - InterTypeMethodDeclaration itdm = - new InterTypeMethodDeclarationImpl( - this,ann.targetType(),ann.modifiers(), - ann.name(),m); - itdms.add(itdm); - } - } - addAnnotationStyleITDMethods(itdms,false); - this.declaredITDMethods = new InterTypeMethodDeclaration[itdms.size()]; - itdms.toArray(this.declaredITDMethods); - } - return this.declaredITDMethods; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getITDMethod(java.lang.String, java.lang.Class, java.lang.Class...) - */ - public InterTypeMethodDeclaration getITDMethod(String name, AjType target, - AjType... parameterTypes) - throws NoSuchMethodException { - InterTypeMethodDeclaration[] itdms = getITDMethods(); - outer: for (InterTypeMethodDeclaration itdm : itdms) { - try { - if (!itdm.getName().equals(name)) continue; - AjType itdTarget = itdm.getTargetType(); - if (itdTarget.equals(target)) { - AjType[] ptypes = itdm.getParameterTypes(); - if (ptypes.length == parameterTypes.length) { - for (int i = 0; i < ptypes.length; i++) { - if (!ptypes[i].equals(parameterTypes[i])) - continue outer; - } - return itdm; - } - } - } catch (ClassNotFoundException cnf) { - // just move on to the next one - } - } - throw new NoSuchMethodException(name); - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getITDMethods() - */ - public InterTypeMethodDeclaration[] getITDMethods() { - if (this.itdMethods == null) { - List itdms = new ArrayList(); - Method[] baseMethods = clazz.getDeclaredMethods(); - for (Method m : baseMethods) { - if (!m.getName().contains("ajc$interMethod$")) continue; - if (m.isAnnotationPresent(ajcITD.class)) { - ajcITD ann = m.getAnnotation(ajcITD.class); - if (!Modifier.isPublic(ann.modifiers())) continue; - InterTypeMethodDeclaration itdm = - new InterTypeMethodDeclarationImpl( - this,ann.targetType(),ann.modifiers(), - ann.name(),m); - itdms.add(itdm); - } - } - addAnnotationStyleITDMethods(itdms,true); - this.itdMethods = new InterTypeMethodDeclaration[itdms.size()]; - itdms.toArray(this.itdMethods); - } - return this.itdMethods; - } - - private void addAnnotationStyleITDMethods(List toList, boolean publicOnly) { - if (isAspect()) { - for (Field f : clazz.getDeclaredFields()) { - if (!f.getType().isInterface()) continue; - if (f.isAnnotationPresent(org.aspectj.lang.annotation.DeclareParents.class)) { - Class decPAnnClass = org.aspectj.lang.annotation.DeclareParents.class; - org.aspectj.lang.annotation.DeclareParents decPAnn = f.getAnnotation(decPAnnClass); - if (decPAnn.defaultImpl() == decPAnnClass) continue; // doesn't contribute members... - for (Method itdM : f.getType().getDeclaredMethods()) { - if (!Modifier.isPublic(itdM.getModifiers()) && publicOnly) continue; - InterTypeMethodDeclaration itdm = new InterTypeMethodDeclarationImpl( - this, AjTypeSystem.getAjType(f.getType()), itdM, - Modifier.PUBLIC - ); - toList.add(itdm); - } - } - } - } - } - - private void addAnnotationStyleITDFields(List toList, boolean publicOnly) { - //AV: I think it is meaningless - //@AJ decp is interface driven ie no field - return; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getDeclaredITDConstructor(java.lang.Class, java.lang.Class...) - */ - public InterTypeConstructorDeclaration getDeclaredITDConstructor( - AjType target, AjType... parameterTypes) throws NoSuchMethodException { - InterTypeConstructorDeclaration[] itdcs = getDeclaredITDConstructors(); - outer: for (InterTypeConstructorDeclaration itdc : itdcs) { - try { - AjType itdTarget = itdc.getTargetType(); - if (itdTarget.equals(target)) { - AjType[] ptypes = itdc.getParameterTypes(); - if (ptypes.length == parameterTypes.length) { - for (int i = 0; i < ptypes.length; i++) { - if (!ptypes[i].equals(parameterTypes[i])) - continue outer; - } - return itdc; - } - } - } catch (ClassNotFoundException cnf) { - // just move on to the next one - } - } - throw new NoSuchMethodException(); - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getDeclaredITDConstructors() - */ - public InterTypeConstructorDeclaration[] getDeclaredITDConstructors() { - if (this.declaredITDCons == null) { - List itdcs = new ArrayList(); - Method[] baseMethods = clazz.getDeclaredMethods(); - for (Method m : baseMethods) { - if (!m.getName().contains("ajc$postInterConstructor")) continue; - if (m.isAnnotationPresent(ajcITD.class)) { - ajcITD ann = m.getAnnotation(ajcITD.class); - InterTypeConstructorDeclaration itdc = - new InterTypeConstructorDeclarationImpl(this,ann.targetType(),ann.modifiers(),m); - itdcs.add(itdc); - } - } - this.declaredITDCons = new InterTypeConstructorDeclaration[itdcs.size()]; - itdcs.toArray(this.declaredITDCons); - } - return this.declaredITDCons; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getITDConstructor(java.lang.Class, java.lang.Class...) - */ - public InterTypeConstructorDeclaration getITDConstructor(AjType target, - AjType... parameterTypes) throws NoSuchMethodException { - InterTypeConstructorDeclaration[] itdcs = getITDConstructors(); - outer: for (InterTypeConstructorDeclaration itdc : itdcs) { - try { - AjType itdTarget = itdc.getTargetType(); - if (itdTarget.equals(target)) { - AjType[] ptypes = itdc.getParameterTypes(); - if (ptypes.length == parameterTypes.length) { - for (int i = 0; i < ptypes.length; i++) { - if (!ptypes[i].equals(parameterTypes[i])) - continue outer; - } - return itdc; - } - } - } catch (ClassNotFoundException cnf) { - // just move on to the next one - } - } - throw new NoSuchMethodException(); - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getITDConstructors() - */ - public InterTypeConstructorDeclaration[] getITDConstructors() { - if (this.itdCons == null) { - List itdcs = new ArrayList(); - Method[] baseMethods = clazz.getMethods(); - for (Method m : baseMethods) { - if (!m.getName().contains("ajc$postInterConstructor")) continue; - if (m.isAnnotationPresent(ajcITD.class)) { - ajcITD ann = m.getAnnotation(ajcITD.class); - if (!Modifier.isPublic(ann.modifiers())) continue; - InterTypeConstructorDeclaration itdc = - new InterTypeConstructorDeclarationImpl(this,ann.targetType(),ann.modifiers(),m); - itdcs.add(itdc); - } - } - this.itdCons = new InterTypeConstructorDeclaration[itdcs.size()]; - itdcs.toArray(this.itdCons); - } - return this.itdCons; } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getDeclaredITDField(java.lang.String, java.lang.Class) - */ - public InterTypeFieldDeclaration getDeclaredITDField(String name, - AjType target) throws NoSuchFieldException { - InterTypeFieldDeclaration[] itdfs = getDeclaredITDFields(); - for (InterTypeFieldDeclaration itdf : itdfs) { - if (itdf.getName().equals(name)) { - try { - AjType itdTarget = itdf.getTargetType(); - if (itdTarget.equals(target)) return itdf; - } catch (ClassNotFoundException cnfEx) { - // move on to next field - } - } - } - throw new NoSuchFieldException(name); - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getDeclaredITDFields() - */ - public InterTypeFieldDeclaration[] getDeclaredITDFields() { - List itdfs = new ArrayList(); - if (this.declaredITDFields == null) { - Method[] baseMethods = clazz.getDeclaredMethods(); - for(Method m : baseMethods) { - if (m.isAnnotationPresent(ajcITD.class)) { - if (!m.getName().contains("ajc$interFieldInit")) continue; - ajcITD ann = m.getAnnotation(ajcITD.class); - String interFieldInitMethodName = m.getName(); - String interFieldGetDispatchMethodName = - interFieldInitMethodName.replace("FieldInit","FieldGetDispatch"); - try { - Method dispatch = clazz.getDeclaredMethod(interFieldGetDispatchMethodName, m.getParameterTypes()); - InterTypeFieldDeclaration itdf = new InterTypeFieldDeclarationImpl( - this,ann.targetType(),ann.modifiers(),ann.name(), - AjTypeSystem.getAjType(dispatch.getReturnType()), - dispatch.getGenericReturnType()); - itdfs.add(itdf); - } catch (NoSuchMethodException nsmEx) { - throw new IllegalStateException("Can't find field get dispatch method for " + m.getName()); - } - } - } - addAnnotationStyleITDFields(itdfs, false); - this.declaredITDFields = new InterTypeFieldDeclaration[itdfs.size()]; - itdfs.toArray(this.declaredITDFields); - } - return this.declaredITDFields; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getITDField(java.lang.String, java.lang.Class) - */ - public InterTypeFieldDeclaration getITDField(String name, AjType target) - throws NoSuchFieldException { - InterTypeFieldDeclaration[] itdfs = getITDFields(); - for (InterTypeFieldDeclaration itdf : itdfs) { - if (itdf.getName().equals(name)) { - try { - AjType itdTarget = itdf.getTargetType(); - if (itdTarget.equals(target)) return itdf; - } catch (ClassNotFoundException cnfEx) { - // move on to next field - } - } - } - throw new NoSuchFieldException(name); - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getITDFields() - */ - public InterTypeFieldDeclaration[] getITDFields() { - List itdfs = new ArrayList(); - if (this.itdFields == null) { - Method[] baseMethods = clazz.getMethods(); - for(Method m : baseMethods) { - if (m.isAnnotationPresent(ajcITD.class)) { - ajcITD ann = m.getAnnotation(ajcITD.class); - if (!m.getName().contains("ajc$interFieldInit")) continue; - if (!Modifier.isPublic(ann.modifiers())) continue; - String interFieldInitMethodName = m.getName(); - String interFieldGetDispatchMethodName = - interFieldInitMethodName.replace("FieldInit","FieldGetDispatch"); - try { - Method dispatch = m.getDeclaringClass().getDeclaredMethod(interFieldGetDispatchMethodName, m.getParameterTypes()); - InterTypeFieldDeclaration itdf = new InterTypeFieldDeclarationImpl( - this,ann.targetType(),ann.modifiers(),ann.name(), - AjTypeSystem.getAjType(dispatch.getReturnType()), - dispatch.getGenericReturnType()); - itdfs.add(itdf); - } catch (NoSuchMethodException nsmEx) { - throw new IllegalStateException("Can't find field get dispatch method for " + m.getName()); - } - } - } - addAnnotationStyleITDFields(itdfs, true); - this.itdFields = new InterTypeFieldDeclaration[itdfs.size()]; - itdfs.toArray(this.itdFields); - } - return this.itdFields; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getDeclareErrorOrWarnings() - */ - public DeclareErrorOrWarning[] getDeclareErrorOrWarnings() { - List deows = new ArrayList(); - for (Field field : clazz.getDeclaredFields()) { - try { - if (field.isAnnotationPresent(DeclareWarning.class)) { - DeclareWarning dw = field.getAnnotation(DeclareWarning.class); - if (Modifier.isPublic(field.getModifiers()) && Modifier.isStatic(field.getModifiers())) { - String message = (String) field.get(null); - DeclareErrorOrWarningImpl deow = new DeclareErrorOrWarningImpl(dw.value(),message,false,this); - deows.add(deow); - } - } else if (field.isAnnotationPresent(DeclareError.class)) { - DeclareError de = field.getAnnotation(DeclareError.class); - if (Modifier.isPublic(field.getModifiers()) && Modifier.isStatic(field.getModifiers())) { - String message = (String) field.get(null); - DeclareErrorOrWarningImpl deow = new DeclareErrorOrWarningImpl(de.value(),message,true,this); - deows.add(deow); - } - } - } catch (IllegalArgumentException e) { - // just move on to the next field - } catch (IllegalAccessException e) { - // just move on to the next field - } - } - for (Method method : clazz.getDeclaredMethods()) { - if (method.isAnnotationPresent(ajcDeclareEoW.class)) { - ajcDeclareEoW deowAnn = method.getAnnotation(ajcDeclareEoW.class); - DeclareErrorOrWarning deow = new DeclareErrorOrWarningImpl(deowAnn.pointcut(),deowAnn.message(),deowAnn.isError(),this); - deows.add(deow); - } - } - DeclareErrorOrWarning[] ret = new DeclareErrorOrWarning[deows.size()]; - deows.toArray(ret); - return ret; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getDeclareParents() - */ - public DeclareParents[] getDeclareParents() { - List decps = new ArrayList(); - for (Method method : clazz.getDeclaredMethods()) { - if (method.isAnnotationPresent(ajcDeclareParents.class)) { - ajcDeclareParents decPAnn = method.getAnnotation(ajcDeclareParents.class); - DeclareParentsImpl decp = new DeclareParentsImpl( - decPAnn.targetTypePattern(), - decPAnn.parentTypes(), - decPAnn.isExtends(), - this - ); - decps.add(decp); - } - } - addAnnotationStyleDeclareParents(decps); - if (getSupertype().isAspect()) { - decps.addAll(Arrays.asList(getSupertype().getDeclareParents())); - } - DeclareParents[] ret = new DeclareParents[decps.size()]; - decps.toArray(ret); - return ret; - } - - private void addAnnotationStyleDeclareParents(List toList) { - for (Field f : clazz.getDeclaredFields()) { - if (f.isAnnotationPresent(org.aspectj.lang.annotation.DeclareParents.class)) { - if (!f.getType().isInterface()) continue; - org.aspectj.lang.annotation.DeclareParents ann = f.getAnnotation(org.aspectj.lang.annotation.DeclareParents.class); - String parentType = f.getType().getName(); - DeclareParentsImpl decp = new DeclareParentsImpl( - ann.value(), - parentType, - false, - this - ); - toList.add(decp); - } - } - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getDeclareSofts() - */ - public DeclareSoft[] getDeclareSofts() { - List decs = new ArrayList(); - for (Method method : clazz.getDeclaredMethods()) { - if (method.isAnnotationPresent(ajcDeclareSoft.class)) { - ajcDeclareSoft decSAnn = method.getAnnotation(ajcDeclareSoft.class); - DeclareSoftImpl ds = new DeclareSoftImpl( - this, - decSAnn.pointcut(), - decSAnn.exceptionType() - ); - decs.add(ds); - } - } - if (getSupertype().isAspect()) { - decs.addAll(Arrays.asList(getSupertype().getDeclareSofts())); - } - DeclareSoft[] ret = new DeclareSoft[decs.size()]; - decs.toArray(ret); - return ret; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getDeclareAnnotations() - */ - public DeclareAnnotation[] getDeclareAnnotations() { - List decAs = new ArrayList(); - for (Method method : clazz.getDeclaredMethods()) { - if (method.isAnnotationPresent(ajcDeclareAnnotation.class)) { - ajcDeclareAnnotation decAnn = method.getAnnotation(ajcDeclareAnnotation.class); - // the target annotation is on this method... - Annotation targetAnnotation = null; - Annotation[] anns = method.getAnnotations(); - for (Annotation ann: anns) { - if (ann.annotationType() != ajcDeclareAnnotation.class) { - // this must be the one... - targetAnnotation = ann; - break; - } - } - DeclareAnnotationImpl da = new DeclareAnnotationImpl( - this, - decAnn.kind(), - decAnn.pattern(), - targetAnnotation, - decAnn.annotation() - ); - decAs.add(da); - } - } - if (getSupertype().isAspect()) { - decAs.addAll(Arrays.asList(getSupertype().getDeclareAnnotations())); - } - DeclareAnnotation[] ret = new DeclareAnnotation[decAs.size()]; - decAs.toArray(ret); - return ret; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getDeclarePrecedence() - */ - public DeclarePrecedence[] getDeclarePrecedence() { - List decps = new ArrayList(); - - // @AspectJ Style - if (clazz.isAnnotationPresent(org.aspectj.lang.annotation.DeclarePrecedence.class)) { - org.aspectj.lang.annotation.DeclarePrecedence ann = - clazz.getAnnotation(org.aspectj.lang.annotation.DeclarePrecedence.class); - DeclarePrecedenceImpl decp = new DeclarePrecedenceImpl( - ann.value(), - this - ); - decps.add(decp); - } - - // annotated code-style - for (Method method : clazz.getDeclaredMethods()) { - if (method.isAnnotationPresent(ajcDeclarePrecedence.class)) { - ajcDeclarePrecedence decPAnn = method.getAnnotation(ajcDeclarePrecedence.class); - DeclarePrecedenceImpl decp = new DeclarePrecedenceImpl( - decPAnn.value(), - this - ); - decps.add(decp); - } - } - if (getSupertype().isAspect()) { - decps.addAll(Arrays.asList(getSupertype().getDeclarePrecedence())); - } - DeclarePrecedence[] ret = new DeclarePrecedence[decps.size()]; - decps.toArray(ret); - return ret; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getEnumConstants() - */ - public T[] getEnumConstants() { - return clazz.getEnumConstants(); - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#getTypeParameters() - */ - public TypeVariable>[] getTypeParameters() { - return clazz.getTypeParameters(); - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#isEnum() - */ - public boolean isEnum() { - return clazz.isEnum(); - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#isInstance(java.lang.Object) - */ - public boolean isInstance(Object o) { - return clazz.isInstance(o); - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#isInterface() - */ - public boolean isInterface() { - return clazz.isInterface(); - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#isLocalClass() - */ - public boolean isLocalClass() { - return clazz.isLocalClass() && !isAspect(); - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#isMemberClass() - */ - public boolean isMemberClass() { - return clazz.isMemberClass() && !isAspect(); - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#isArray() - */ - public boolean isArray() { - return clazz.isArray(); - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#isPrimitive() - */ - public boolean isPrimitive() { - return clazz.isPrimitive(); - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#isAspect() - */ - public boolean isAspect() { - return clazz.getAnnotation(Aspect.class) != null; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.AjType#isMemberAspect() - */ - public boolean isMemberAspect() { - return clazz.isMemberClass() && isAspect(); - } - - public boolean isPrivileged() { - return isAspect() && clazz.isAnnotationPresent(ajcPrivileged.class); - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof AjTypeImpl)) return false; - AjTypeImpl other = (AjTypeImpl) obj; - return other.clazz.equals(clazz); - } - - @Override - public int hashCode() { - return clazz.hashCode(); - } - - private AjType[] toAjTypeArray(Class[] classes) { - AjType[] ajtypes = new AjType[classes.length]; - for (int i = 0; i < ajtypes.length; i++) { - ajtypes[i] = AjTypeSystem.getAjType(classes[i]); - } - return ajtypes; - } - - private Class[] toClassArray(AjType[] ajTypes) { - Class[] classes = new Class[ajTypes.length]; - for (int i = 0; i < classes.length; i++) { - classes[i] = ajTypes[i].getJavaClass(); - } - return classes; - } - - public String toString() { return getName(); } - -} diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/DeclareAnnotationImpl.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/DeclareAnnotationImpl.java deleted file mode 100644 index bcc91b987..000000000 --- a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/DeclareAnnotationImpl.java +++ /dev/null @@ -1,115 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.internal.lang.reflect; - -import java.lang.annotation.Annotation; - -import org.aspectj.lang.reflect.AjType; -import org.aspectj.lang.reflect.DeclareAnnotation; -import org.aspectj.lang.reflect.SignaturePattern; -import org.aspectj.lang.reflect.TypePattern; - -/** - * @author colyer - * - */ -public class DeclareAnnotationImpl implements DeclareAnnotation { - - private Annotation theAnnotation; - private String annText; - private AjType declaringType; - private DeclareAnnotation.Kind kind; - private TypePattern typePattern; - private SignaturePattern signaturePattern; - - public DeclareAnnotationImpl(AjType declaring, String kindString, String pattern, Annotation ann, String annText) { - this.declaringType = declaring; - if (kindString.equals("at_type")) this.kind = DeclareAnnotation.Kind.Type; - else if (kindString.equals("at_field")) this.kind = DeclareAnnotation.Kind.Field; - else if (kindString.equals("at_method")) this.kind = DeclareAnnotation.Kind.Method; - else if (kindString.equals("at_constructor")) this.kind = DeclareAnnotation.Kind.Constructor; - else throw new IllegalStateException("Unknown declare annotation kind: " + kindString); - if (kind == DeclareAnnotation.Kind.Type) { - this.typePattern = new TypePatternImpl(pattern); - } else { - this.signaturePattern = new SignaturePatternImpl(pattern); - } - this.theAnnotation = ann; - this.annText = annText; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.DeclareAnnotation#getDeclaringType() - */ - public AjType getDeclaringType() { - return this.declaringType; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.DeclareAnnotation#getKind() - */ - public Kind getKind() { - return this.kind; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.DeclareAnnotation#getSignaturePattern() - */ - public SignaturePattern getSignaturePattern() { - return this.signaturePattern; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.DeclareAnnotation#getTypePattern() - */ - public TypePattern getTypePattern() { - return this.typePattern; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.DeclareAnnotation#getAnnotation() - */ - public Annotation getAnnotation() { - return this.theAnnotation; - } - - public String getAnnotationAsText() { - return this.annText; - } - - public String toString() { - StringBuffer sb = new StringBuffer(); - sb.append("declare @"); - switch(getKind()) { - case Type: - sb.append("type : "); - sb.append(getTypePattern().asString()); - break; - case Method: - sb.append("method : "); - sb.append(getSignaturePattern().asString()); - break; - case Field: - sb.append("field : "); - sb.append(getSignaturePattern().asString()); - break; - case Constructor: - sb.append("constructor : "); - sb.append(getSignaturePattern().asString()); - break; - } - sb.append(" : "); - sb.append(getAnnotationAsText()); - return sb.toString(); - } - -} diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/DeclareErrorOrWarningImpl.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/DeclareErrorOrWarningImpl.java deleted file mode 100644 index 5420f8274..000000000 --- a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/DeclareErrorOrWarningImpl.java +++ /dev/null @@ -1,71 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.internal.lang.reflect; - -import org.aspectj.lang.reflect.AjType; -import org.aspectj.lang.reflect.DeclareErrorOrWarning; -import org.aspectj.lang.reflect.PointcutExpression; - -/** - * @author colyer - * - */ -public class DeclareErrorOrWarningImpl implements DeclareErrorOrWarning { - - private PointcutExpression pc; - private String msg; - private boolean isError; - private AjType declaringType; - - public DeclareErrorOrWarningImpl(String pointcut, String message, boolean isError, AjType decType) { - this.pc = new PointcutExpressionImpl(pointcut); - this.msg = message; - this.isError = isError; - this.declaringType = decType; - } - - public AjType getDeclaringType() { return this.declaringType; } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.DeclareErrorOrWarning#getPointcutExpression() - */ - public PointcutExpression getPointcutExpression() { - return pc; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.DeclareErrorOrWarning#getMessage() - */ - public String getMessage() { - return msg; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.DeclareErrorOrWarning#isError() - */ - public boolean isError() { - return isError; - } - - public String toString() { - StringBuffer sb = new StringBuffer(); - sb.append("declare "); - sb.append(isError() ? "error : " : "warning : "); - sb.append(getPointcutExpression().asString()); - sb.append(" : "); - sb.append("\""); - sb.append(getMessage()); - sb.append("\""); - return sb.toString(); - } - -} diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/DeclareParentsImpl.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/DeclareParentsImpl.java deleted file mode 100644 index 4f5720667..000000000 --- a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/DeclareParentsImpl.java +++ /dev/null @@ -1,98 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.internal.lang.reflect; - -import java.lang.reflect.Type; - -import org.aspectj.lang.reflect.AjType; -import org.aspectj.lang.reflect.DeclareParents; -import org.aspectj.lang.reflect.TypePattern; - -/** - * @author colyer - * - */ -public class DeclareParentsImpl implements DeclareParents { - - private AjType declaringType; - private TypePattern targetTypesPattern; - private Type[] parents; - private String parentsString; - private String firstMissingTypeName; - private boolean isExtends; - private boolean parentsError = false; - - /** - * Parents arg is a comma-separate list of type names that needs to be turned into - * AjTypes - */ - public DeclareParentsImpl(String targets, String parentsAsString, boolean isExtends, AjType declaring) - { - this.targetTypesPattern = new TypePatternImpl(targets); - this.isExtends = isExtends; - this.declaringType = declaring; - this.parentsString = parentsAsString; - try { - this.parents = StringToType.commaSeparatedListToTypeArray(parentsAsString, declaring.getJavaClass()); - } catch (ClassNotFoundException cnfEx) { - this.parentsError = true; - this.firstMissingTypeName = cnfEx.getMessage(); - } - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.DeclareParents#getDeclaringType() - */ - public AjType getDeclaringType() { - return this.declaringType; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.DeclareParents#getTargetTypesPattern() - */ - public TypePattern getTargetTypesPattern() { - return this.targetTypesPattern; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.DeclareParents#isExtends() - */ - public boolean isExtends() { - return this.isExtends; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.DeclareParents#isImplements() - */ - public boolean isImplements() { - return !this.isExtends; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.DeclareParents#getParentTypes() - */ - public Type[] getParentTypes() throws ClassNotFoundException { - if (parentsError) { - throw new ClassNotFoundException(this.firstMissingTypeName); - } - return this.parents; - } - - public String toString() { - StringBuffer sb = new StringBuffer(); - sb.append("declare parents : "); - sb.append(getTargetTypesPattern().asString()); - sb.append(isExtends() ? " extends " : " implements "); - sb.append(this.parentsString); - return sb.toString(); - } -} diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/DeclarePrecedenceImpl.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/DeclarePrecedenceImpl.java deleted file mode 100644 index 7188606c6..000000000 --- a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/DeclarePrecedenceImpl.java +++ /dev/null @@ -1,62 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.internal.lang.reflect; - -import java.util.StringTokenizer; - -import org.aspectj.lang.reflect.AjType; -import org.aspectj.lang.reflect.DeclarePrecedence; -import org.aspectj.lang.reflect.TypePattern; - -/** - * @author colyer - * - */ -public class DeclarePrecedenceImpl implements DeclarePrecedence { - - private AjType declaringType; - private TypePattern[] precedenceList; - private String precedenceString; - - public DeclarePrecedenceImpl(String precedenceList, AjType declaring) { - this.declaringType = declaring; - this.precedenceString = precedenceList; - String toTokenize = precedenceList; - if (toTokenize.startsWith("(")) { - toTokenize = toTokenize.substring(1,toTokenize.length() - 1); - } - StringTokenizer strTok = new StringTokenizer(toTokenize,","); - this.precedenceList = new TypePattern[strTok.countTokens()]; - for (int i = 0; i < this.precedenceList.length; i++) { - this.precedenceList[i] = new TypePatternImpl(strTok.nextToken().trim()); - } - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.DeclarePrecedence#getDeclaringType() - */ - public AjType getDeclaringType() { - return this.declaringType; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.DeclarePrecedence#getPrecedenceOrder() - */ - public TypePattern[] getPrecedenceOrder() { - return this.precedenceList; - } - - public String toString() { - return "declare precedence : " + this.precedenceString; - } - -} diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/DeclareSoftImpl.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/DeclareSoftImpl.java deleted file mode 100644 index 4c8ea4ead..000000000 --- a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/DeclareSoftImpl.java +++ /dev/null @@ -1,76 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.internal.lang.reflect; - -import org.aspectj.lang.reflect.AjType; -import org.aspectj.lang.reflect.AjTypeSystem; -import org.aspectj.lang.reflect.DeclareSoft; -import org.aspectj.lang.reflect.PointcutExpression; - -/** - * @author colyer - * - */ -public class DeclareSoftImpl implements DeclareSoft { - - private AjType declaringType; - private PointcutExpression pointcut; - private AjType exceptionType; - private String missingTypeName; - - - public DeclareSoftImpl(AjType declaringType, String pcut, String exceptionTypeName) { - this.declaringType = declaringType; - this.pointcut = new PointcutExpressionImpl(pcut); - try { - ClassLoader cl = declaringType.getJavaClass().getClassLoader(); - this.exceptionType = AjTypeSystem.getAjType(Class.forName(exceptionTypeName,false,cl)); - } catch (ClassNotFoundException ex) { - this.missingTypeName = exceptionTypeName; - } - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.DeclareSoft#getDeclaringType() - */ - public AjType getDeclaringType() { - return this.declaringType; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.DeclareSoft#getSoftenedExceptionType() - */ - public AjType getSoftenedExceptionType() throws ClassNotFoundException { - if (this.missingTypeName != null) throw new ClassNotFoundException(this.missingTypeName); - return this.exceptionType; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.DeclareSoft#getPointcutExpression() - */ - public PointcutExpression getPointcutExpression() { - return this.pointcut; - } - - public String toString() { - StringBuffer sb = new StringBuffer(); - sb.append("declare soft : "); - if (this.missingTypeName != null) { - sb.append(this.exceptionType.getName()); - } else { - sb.append(this.missingTypeName); - } - sb.append(" : "); - sb.append(getPointcutExpression().asString()); - return sb.toString(); - } -} diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/InterTypeConstructorDeclarationImpl.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/InterTypeConstructorDeclarationImpl.java deleted file mode 100644 index 9b80263a3..000000000 --- a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/InterTypeConstructorDeclarationImpl.java +++ /dev/null @@ -1,100 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.internal.lang.reflect; - -import java.lang.reflect.Method; -import java.lang.reflect.Type; - -import org.aspectj.lang.reflect.AjType; -import org.aspectj.lang.reflect.AjTypeSystem; -import org.aspectj.lang.reflect.InterTypeConstructorDeclaration; - -/** - * @author colyer - * - */ -public class InterTypeConstructorDeclarationImpl extends - InterTypeDeclarationImpl implements InterTypeConstructorDeclaration { - - private Method baseMethod; - - /** - * @param decType - * @param target - * @param mods - */ - public InterTypeConstructorDeclarationImpl(AjType decType, - String target, int mods, Method baseMethod) { - super(decType, target, mods); - this.baseMethod = baseMethod; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.InterTypeConstructorDeclaration#getParameters() - */ - public AjType[] getParameterTypes() { - Class[] baseTypes = baseMethod.getParameterTypes(); - AjType[] ret = new AjType[baseTypes.length-1]; - for (int i = 1; i < baseTypes.length; i++) { - ret[i-1] = AjTypeSystem.getAjType(baseTypes[i]); - } - return ret; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.InterTypeConstructorDeclaration#getGenericParameters() - */ - public Type[] getGenericParameterTypes() { - Type[] baseTypes = baseMethod.getGenericParameterTypes(); - Type[] ret = new AjType[baseTypes.length-1]; - for (int i = 1; i < baseTypes.length; i++) { - if (baseTypes[i] instanceof Class) { - ret[i-1] = AjTypeSystem.getAjType((Class)baseTypes[i]); - } else { - ret[i-1] = baseTypes[i]; - } - } - return ret; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.InterTypeConstructorDeclaration#getDeclaredExceptionTypes() - */ - public AjType[] getExceptionTypes() { - Class[] baseTypes = baseMethod.getExceptionTypes(); - AjType[] ret = new AjType[baseTypes.length]; - for (int i = 0; i < baseTypes.length; i++) { - ret[i] = AjTypeSystem.getAjType(baseTypes[i]); - } - return ret; - } - - public String toString() { - StringBuffer sb = new StringBuffer(); - sb.append(java.lang.reflect.Modifier.toString(getModifiers())); - sb.append(" "); - sb.append(this.targetTypeName); - sb.append(".new"); - sb.append("("); - AjType[] pTypes = getParameterTypes(); - for(int i = 0; i < (pTypes.length - 1); i++) { - sb.append(pTypes[i].toString()); - sb.append(", "); - } - if (pTypes.length > 0) { - sb.append(pTypes[pTypes.length -1].toString()); - } - sb.append(")"); - return sb.toString(); - } - -} diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/InterTypeDeclarationImpl.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/InterTypeDeclarationImpl.java deleted file mode 100644 index b4bb23aab..000000000 --- a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/InterTypeDeclarationImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.internal.lang.reflect; - -import org.aspectj.lang.reflect.AjType; -import org.aspectj.lang.reflect.InterTypeDeclaration; - -/** - * @author colyer - * - */ -public class InterTypeDeclarationImpl implements InterTypeDeclaration { - - private AjType declaringType; - protected String targetTypeName; - private AjType targetType; - private int modifiers; - - public InterTypeDeclarationImpl(AjType decType, String target, int mods) { - this.declaringType = decType; - this.targetTypeName = target; - this.modifiers = mods; - try { - this.targetType = (AjType) StringToType.stringToType(target, decType.getJavaClass()); - } catch (ClassNotFoundException cnf) { - // we'll only report this later if the user asks for the target type. - } - } - - public InterTypeDeclarationImpl(AjType decType, AjType targetType, int mods) { - this.declaringType = decType; - this.targetType = targetType; - this.targetTypeName = targetType.getName(); - this.modifiers = mods; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.InterTypeDeclaration#getDeclaringType() - */ - public AjType getDeclaringType() { - return this.declaringType; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.InterTypeDeclaration#getTargetType() - */ - public AjType getTargetType() throws ClassNotFoundException { - if (this.targetType == null) throw new ClassNotFoundException(this.targetTypeName); - return this.targetType; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.InterTypeDeclaration#getModifiers() - */ - public int getModifiers() { - return this.modifiers; - } - -} diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/InterTypeFieldDeclarationImpl.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/InterTypeFieldDeclarationImpl.java deleted file mode 100644 index 2370919c0..000000000 --- a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/InterTypeFieldDeclarationImpl.java +++ /dev/null @@ -1,90 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.internal.lang.reflect; - -import java.lang.reflect.Field; -import java.lang.reflect.Type; - -import org.aspectj.lang.reflect.AjType; -import org.aspectj.lang.reflect.AjTypeSystem; -import org.aspectj.lang.reflect.InterTypeFieldDeclaration; - -/** - * @author colyer - * - */ -public class InterTypeFieldDeclarationImpl extends InterTypeDeclarationImpl - implements InterTypeFieldDeclaration { - - private String name; - private AjType type; - private Type genericType; - - /** - * @param decType - * @param target - * @param mods - */ - public InterTypeFieldDeclarationImpl(AjType decType, String target, - int mods, String name, AjType type, Type genericType) { - super(decType, target, mods); - this.name = name; - this.type = type; - this.genericType = genericType; - } - - public InterTypeFieldDeclarationImpl(AjType decType, AjType targetType, Field base) { - super(decType,targetType,base.getModifiers()); - this.name = base.getName(); - this.type = AjTypeSystem.getAjType(base.getType()); - Type gt = base.getGenericType(); - if (gt instanceof Class) { - this.genericType = AjTypeSystem.getAjType((Class)gt); - } else { - this.genericType = gt; - } - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.InterTypeFieldDeclaration#getName() - */ - public String getName() { - return this.name; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.InterTypeFieldDeclaration#getType() - */ - public AjType getType() { - return this.type; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.InterTypeFieldDeclaration#getGenericType() - */ - public Type getGenericType() { - return this.genericType; - } - - public String toString() { - StringBuffer sb = new StringBuffer(); - sb.append(java.lang.reflect.Modifier.toString(getModifiers())); - sb.append(" "); - sb.append(getType().toString()); - sb.append(" "); - sb.append(this.targetTypeName); - sb.append("."); - sb.append(getName()); - return sb.toString(); - } - -} diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/InterTypeMethodDeclarationImpl.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/InterTypeMethodDeclarationImpl.java deleted file mode 100644 index eb085a055..000000000 --- a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/InterTypeMethodDeclarationImpl.java +++ /dev/null @@ -1,148 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.internal.lang.reflect; - -import java.lang.reflect.Method; -import java.lang.reflect.Type; -import java.lang.reflect.TypeVariable; - -import org.aspectj.lang.reflect.AjType; -import org.aspectj.lang.reflect.AjTypeSystem; -import org.aspectj.lang.reflect.InterTypeMethodDeclaration; - -/** - * @author colyer - * - */ -public class InterTypeMethodDeclarationImpl extends InterTypeDeclarationImpl - implements InterTypeMethodDeclaration { - - private String name; - private Method baseMethod; - private int parameterAdjustmentFactor = 1; // no of fake params at start of baseMethod - private AjType[] parameterTypes; - private Type[] genericParameterTypes; - private AjType returnType; - private Type genericReturnType; - private AjType[] exceptionTypes; - - /** - * @param decType - * @param target - * @param mods - */ - public InterTypeMethodDeclarationImpl(AjType decType, String target, - int mods, String name, Method itdInterMethod) { - super(decType, target, mods); - this.name = name; - this.baseMethod = itdInterMethod; - } - - public InterTypeMethodDeclarationImpl(AjType decType, AjType targetType, Method base, int modifiers) { - super(decType,targetType,modifiers); - this.parameterAdjustmentFactor = 0; - this.name = base.getName(); - this.baseMethod = base; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.InterTypeMethodDeclaration#getName() - */ - public String getName() { - return this.name; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.InterTypeMethodDeclaration#getReturnType() - */ - public AjType getReturnType() { - return AjTypeSystem.getAjType(baseMethod.getReturnType()); - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.InterTypeMethodDeclaration#getGenericReturnType() - */ - public Type getGenericReturnType() { - Type gRet = baseMethod.getGenericReturnType(); - if (gRet instanceof Class) { - return AjTypeSystem.getAjType((Class)gRet); - } - return gRet; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.InterTypeMethodDeclaration#getParameters() - */ - public AjType[] getParameterTypes() { - Class[] baseTypes = baseMethod.getParameterTypes(); - AjType[] ret = new AjType[baseTypes.length -parameterAdjustmentFactor]; - for (int i = parameterAdjustmentFactor; i < baseTypes.length; i++) { - ret[i-parameterAdjustmentFactor] = AjTypeSystem.getAjType(baseTypes[i]); - } - return ret; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.InterTypeMethodDeclaration#getGenericParameters() - */ - public Type[] getGenericParameterTypes() { - Type[] baseTypes = baseMethod.getGenericParameterTypes(); - Type[] ret = new AjType[baseTypes.length-parameterAdjustmentFactor]; - for (int i = parameterAdjustmentFactor; i < baseTypes.length; i++) { - if (baseTypes[i] instanceof Class) { - ret[i-parameterAdjustmentFactor] = AjTypeSystem.getAjType((Class)baseTypes[i]); - } else { - ret[i-parameterAdjustmentFactor] = baseTypes[i]; - } - } - return ret; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.InterTypeMethodDeclaration#getTypeParameters() - */ - public TypeVariable[] getTypeParameters() { - return baseMethod.getTypeParameters(); - } - - public AjType[] getExceptionTypes() { - Class[] baseTypes = baseMethod.getExceptionTypes(); - AjType[] ret = new AjType[baseTypes.length]; - for (int i = 0; i < baseTypes.length; i++) { - ret[i] = AjTypeSystem.getAjType(baseTypes[i]); - } - return ret; - } - - public String toString() { - StringBuffer sb = new StringBuffer(); - sb.append(java.lang.reflect.Modifier.toString(getModifiers())); - sb.append(" "); - sb.append(getReturnType().toString()); - sb.append(" "); - sb.append(this.targetTypeName); - sb.append("."); - sb.append(getName()); - sb.append("("); - AjType[] pTypes = getParameterTypes(); - for(int i = 0; i < (pTypes.length - 1); i++) { - sb.append(pTypes[i].toString()); - sb.append(", "); - } - if (pTypes.length > 0) { - sb.append(pTypes[pTypes.length -1].toString()); - } - sb.append(")"); - return sb.toString(); - } - -} diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/PerClauseImpl.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/PerClauseImpl.java deleted file mode 100644 index 663a44c20..000000000 --- a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/PerClauseImpl.java +++ /dev/null @@ -1,39 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.internal.lang.reflect; - -import org.aspectj.lang.reflect.PerClause; -import org.aspectj.lang.reflect.PerClauseKind; - -/** - * @author colyer - * - */ -public class PerClauseImpl implements PerClause { - - private final PerClauseKind kind; - - protected PerClauseImpl(PerClauseKind kind) { - this.kind = kind; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.PerClause#getKind() - */ - public PerClauseKind getKind() { - return kind; - } - - public String toString() { - return "issingleton()"; - } -} diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/PointcutBasedPerClauseImpl.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/PointcutBasedPerClauseImpl.java deleted file mode 100644 index 5049d3a42..000000000 --- a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/PointcutBasedPerClauseImpl.java +++ /dev/null @@ -1,49 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.internal.lang.reflect; - -import org.aspectj.lang.reflect.PerClauseKind; -import org.aspectj.lang.reflect.PointcutBasedPerClause; -import org.aspectj.lang.reflect.PointcutExpression; - -/** - * @author colyer - * - */ -public class PointcutBasedPerClauseImpl extends PerClauseImpl implements - PointcutBasedPerClause { - - private final PointcutExpression pointcutExpression; - - public PointcutBasedPerClauseImpl(PerClauseKind kind, - String pointcutExpression) { - super(kind); - this.pointcutExpression = new PointcutExpressionImpl(pointcutExpression); - } - - public PointcutExpression getPointcutExpression() { - return pointcutExpression; - } - - public String toString() { - StringBuffer sb = new StringBuffer(); - switch(getKind()) { - case PERCFLOW: sb.append("percflow("); break; - case PERCFLOWBELOW: sb.append("percflowbelow("); break; - case PERTARGET: sb.append("pertarget("); break; - case PERTHIS: sb.append("perthis("); break; - } - sb.append(this.pointcutExpression.asString()); - sb.append(")"); - return sb.toString(); - } -} diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/PointcutExpressionImpl.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/PointcutExpressionImpl.java deleted file mode 100644 index facf7d99d..000000000 --- a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/PointcutExpressionImpl.java +++ /dev/null @@ -1,32 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.internal.lang.reflect; - -import org.aspectj.lang.reflect.PointcutExpression; - -/** - * @author colyer - * - */ -public class PointcutExpressionImpl implements PointcutExpression { - private String expression; - - public PointcutExpressionImpl(String aPointcutExpression) { - this.expression = aPointcutExpression; - } - - public String asString() { - return expression; - } - - public String toString() { return asString(); } -} diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/PointcutImpl.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/PointcutImpl.java deleted file mode 100644 index b94f1c864..000000000 --- a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/PointcutImpl.java +++ /dev/null @@ -1,100 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.internal.lang.reflect; - -import java.lang.reflect.Method; -import java.util.StringTokenizer; - -import org.aspectj.lang.reflect.AjType; -import org.aspectj.lang.reflect.AjTypeSystem; -import org.aspectj.lang.reflect.Pointcut; -import org.aspectj.lang.reflect.PointcutExpression; - -/** - * @author colyer - * - */ -public class PointcutImpl implements Pointcut { - - private final String name; - private final PointcutExpression pc; - private final Method baseMethod; - private final AjType declaringType; - private String[] parameterNames = new String[0]; - - protected PointcutImpl(String name, String pc, Method method, AjType declaringType, String pNames) { - this.name = name; - this.pc = new PointcutExpressionImpl(pc); - this.baseMethod = method; - this.declaringType = declaringType; - this.parameterNames = splitOnComma(pNames); - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.Pointcut#getPointcutExpression() - */ - public PointcutExpression getPointcutExpression() { - return pc; - } - - public String getName() { - return name; - } - - public int getModifiers() { - return baseMethod.getModifiers(); - } - - public AjType[] getParameterTypes() { - Class[] baseParamTypes = baseMethod.getParameterTypes(); - AjType[] ajParamTypes = new AjType[baseParamTypes.length]; - for (int i = 0; i < ajParamTypes.length; i++) { - ajParamTypes[i] = AjTypeSystem.getAjType(baseParamTypes[i]); - } - return ajParamTypes; - } - - public AjType getDeclaringType() { - return declaringType; - } - - public String[] getParameterNames() { - return parameterNames; - } - - private String[] splitOnComma(String s) { - StringTokenizer strTok = new StringTokenizer(s,","); - String[] ret = new String[strTok.countTokens()]; - for (int i = 0; i < ret.length; i++) { - ret[i] = strTok.nextToken().trim(); - } - return ret; - } - - public String toString() { - StringBuffer sb = new StringBuffer(); - sb.append(getName()); - sb.append("("); - AjType[] ptypes = getParameterTypes(); - for (int i = 0; i < ptypes.length; i++) { - sb.append(ptypes[i].getName()); - if (this.parameterNames != null && this.parameterNames[i] != null) { - sb.append(" "); - sb.append(this.parameterNames[i]); - } - if (i+1 < ptypes.length) sb.append(","); - } - sb.append(") : "); - sb.append(getPointcutExpression().asString()); - return sb.toString(); - } -} diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/SignaturePatternImpl.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/SignaturePatternImpl.java deleted file mode 100644 index 9820667d8..000000000 --- a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/SignaturePatternImpl.java +++ /dev/null @@ -1,37 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.internal.lang.reflect; - -import org.aspectj.lang.reflect.SignaturePattern; - -/** - * Basic implementation of signature pattern - * - */ -public class SignaturePatternImpl implements SignaturePattern { - - private String sigPattern; - - public SignaturePatternImpl(String pattern) { - this.sigPattern = pattern; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.SignaturePattern#asString() - */ - public String asString() { - return sigPattern; - } - - public String toString() { return asString(); } - -} diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/StringToType.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/StringToType.java deleted file mode 100644 index 4be9fd71e..000000000 --- a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/StringToType.java +++ /dev/null @@ -1,83 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.internal.lang.reflect; - -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.lang.reflect.TypeVariable; -import java.util.StringTokenizer; - -import org.aspectj.lang.reflect.AjTypeSystem; - -/** - * @author colyer - * Helper class for converting type representations in Strings into java.lang.reflect.Types. - */ -public class StringToType { - - public static Type[] commaSeparatedListToTypeArray(String typeNames, Class classScope) - throws ClassNotFoundException { - StringTokenizer strTok = new StringTokenizer(typeNames,","); - Type[] ret = new Type[strTok.countTokens()]; - int index = 0; - //outer: - while (strTok.hasMoreTokens()) { - String typeName = strTok.nextToken().trim(); - ret[index++] = stringToType(typeName, classScope); - } - return ret; - } - - public static Type stringToType(String typeName, Class classScope) - throws ClassNotFoundException { - try { - if (typeName.indexOf("<") == -1) { - return AjTypeSystem.getAjType(Class.forName(typeName,false,classScope.getClassLoader())); - } else { - return makeParameterizedType(typeName,classScope); - } - } catch (ClassNotFoundException e) { - // could be a type variable - TypeVariable[] tVars = classScope.getTypeParameters(); - for (int i = 0; i < tVars.length; i++) { - if (tVars[i].getName().equals(typeName)) { - return tVars[i]; - } - } - throw new ClassNotFoundException(typeName); - } - } - - private static Type makeParameterizedType(String typeName, Class classScope) - throws ClassNotFoundException { - int paramStart = typeName.indexOf('<'); - String baseName = typeName.substring(0, paramStart); - final Class baseClass = Class.forName(baseName,false,classScope.getClassLoader()); - int paramEnd = typeName.lastIndexOf('>'); - String params = typeName.substring(paramStart+1,paramEnd); - final Type[] typeParams = commaSeparatedListToTypeArray(params,classScope); - return new ParameterizedType() { - - public Type[] getActualTypeArguments() { - return typeParams; - } - - public Type getRawType() { - return baseClass; - } - - public Type getOwnerType() { - return baseClass.getEnclosingClass(); - } - }; - } -} diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/TypePatternBasedPerClauseImpl.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/TypePatternBasedPerClauseImpl.java deleted file mode 100644 index e9bb08573..000000000 --- a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/TypePatternBasedPerClauseImpl.java +++ /dev/null @@ -1,43 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.internal.lang.reflect; - -import org.aspectj.lang.reflect.PerClauseKind; -import org.aspectj.lang.reflect.TypePattern; -import org.aspectj.lang.reflect.TypePatternBasedPerClause; - -/** - * @author colyer - * - */ -public class TypePatternBasedPerClauseImpl extends PerClauseImpl implements - TypePatternBasedPerClause { - - private TypePattern typePattern; - - public TypePatternBasedPerClauseImpl(PerClauseKind kind, String pattern) { - super(kind); - this.typePattern = new TypePatternImpl(pattern); - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.TypePatternBasedPerClause#getTypePattern() - */ - public TypePattern getTypePattern() { - return this.typePattern; - } - - public String toString() { - return "pertypewithin(" + typePattern.asString() + ")"; - } - -} diff --git a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/TypePatternImpl.java b/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/TypePatternImpl.java deleted file mode 100644 index 9973ed3bf..000000000 --- a/aspectj5rt/java5-src/org/aspectj/internal/lang/reflect/TypePatternImpl.java +++ /dev/null @@ -1,37 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.internal.lang.reflect; - -import org.aspectj.lang.reflect.TypePattern; - -/** - * Default impl of a type pattern. - * - */ -public class TypePatternImpl implements TypePattern { - - private String typePattern; - - public TypePatternImpl(String pattern) { - this.typePattern = pattern; - } - - /* (non-Javadoc) - * @see org.aspectj.lang.reflect.TypePattern#asString() - */ - public String asString() { - return this.typePattern; - } - - public String toString() { return asString(); } - -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/Aspects.java b/aspectj5rt/java5-src/org/aspectj/lang/Aspects.java deleted file mode 100644 index e82320c2e..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/Aspects.java +++ /dev/null @@ -1,190 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * initial implementation Alexandre Vasseur - * generic signature update Adrian Colyer - *******************************************************************************/ -package org.aspectj.lang; - - -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.lang.reflect.InvocationTargetException; - -/** - * Handles generic aspectOf method when those are not available in the aspects but added later on - * thru load time weaving. - *

    - * Aspects.aspectOf(..) is doing reflective calls to the aspect aspectOf, so for better performance - * consider using ajc compilation of the aspects and using them as a binary dependancies in your project. - * - * @author Alexandre Vasseur - */ -public class Aspects { - - private final static Class[] EMPTY_CLASS_ARRAY = new Class[0]; - private final static Class[] PEROBJECT_CLASS_ARRAY = new Class[]{Object.class}; - private final static Class[] PERTYPEWITHIN_CLASS_ARRAY = new Class[]{Class.class}; - private final static Object[] EMPTY_OBJECT_ARRAY = new Object[0]; - private final static String ASPECTOF = "aspectOf"; - private final static String HASASPECT = "hasAspect"; - - /** - * Returns the singleton aspect or the percflow / percflowbelow associated with the current thread - * - * @param aspectClass - * @return - * @throws NoAspectBoundException if no such aspect - */ - public static T aspectOf(Class aspectClass) throws NoAspectBoundException { - try { - return (T) getSingletonOrThreadAspectOf(aspectClass).invoke(null, EMPTY_OBJECT_ARRAY); - } catch (InvocationTargetException e) { - //FIXME asc Highly temporary change to see what the build makes of it - dont use 1.4 APIs - throw new NoAspectBoundException(aspectClass.getName(), e);//e.getCause()); - } catch (Exception e) { - throw new NoAspectBoundException(aspectClass.getName(), e); - } - } - - /** - * Returns the perthis / pertarget aspect - * @param aspectClass - * @param perObject - * @return - * @throws NoAspectBoundException if no such aspect, or no aspect bound - */ - public static T aspectOf(Class aspectClass, Object perObject) throws NoAspectBoundException { - try { - return (T) getPerObjectAspectOf(aspectClass).invoke(null, new Object[]{perObject}); - } catch (InvocationTargetException e) { - //FIXME asc Highly temporary change to see what the build makes of it - dont use 1.4 APIs - throw new NoAspectBoundException(aspectClass.getName(), e);//e.getCause()); - } catch (Exception e) { - throw new NoAspectBoundException(aspectClass.getName(), e); - } - } - - /** - * Returns the pertypewithin aspect - * @param aspectClass - * @param perTypeWithin class - * @return - * @throws NoAspectBoundException if no such aspect, or no aspect bound - */ - public static T aspectOf(Class aspectClass, Class perTypeWithin) throws NoAspectBoundException { - try { - return (T) getPerTypeWithinAspectOf(aspectClass).invoke(null, new Object[]{perTypeWithin}); - } catch (InvocationTargetException e) { -// FIXME asc Highly temporary change to see what the build makes of it - dont use 1.4 APIs - throw new NoAspectBoundException(aspectClass.getName(), e);//e.getCause()); - } catch (Exception e) { - throw new NoAspectBoundException(aspectClass.getName(), e); - } - } - - /** - * Returns true if singleton aspect or percflow / percflowbelow aspect is bound - * - * @param aspectClass - * @return - * @throws NoAspectBoundException if not bound - */ - public static boolean hasAspect(Class aspectClass) throws NoAspectBoundException { - try { - return ((Boolean)getSingletonOrThreadHasAspect(aspectClass).invoke(null, EMPTY_OBJECT_ARRAY)).booleanValue(); - } catch (Exception e) { - return false; - } - } - - /** - * Returns true if the perthis / pertarget aspect is bound - * @param aspectClass - * @param perObject - * @return - * @throws NoAspectBoundException if not bound - */ - public static boolean hasAspect(Class aspectClass, Object perObject) throws NoAspectBoundException { - try { - return ((Boolean)getPerObjectHasAspect(aspectClass).invoke(null, new Object[]{perObject})).booleanValue(); - } catch (Exception e) { - return false; - } - } - - /** - * Returns true if the pertypewithin aspect is bound - * @param aspectClass - * @param perTypeWithin class - * @return - * @throws NoAspectBoundException if not bound - */ - public static boolean hasAspect(Class aspectClass, Class perTypeWithin) throws NoAspectBoundException { - try { - return ((Boolean)getPerTypeWithinHasAspect(aspectClass).invoke(null, new Object[]{perTypeWithin})).booleanValue(); - } catch (Exception e) { - return false; - } - } - - // -- aspectOf - - private static Method getSingletonOrThreadAspectOf(Class aspectClass) throws NoSuchMethodException { - Method method = aspectClass.getDeclaredMethod(ASPECTOF, EMPTY_CLASS_ARRAY); - return checkAspectOf(method, aspectClass); - } - - private static Method getPerObjectAspectOf(Class aspectClass) throws NoSuchMethodException { - Method method = aspectClass.getDeclaredMethod(ASPECTOF, PEROBJECT_CLASS_ARRAY); - return checkAspectOf(method, aspectClass); - } - - private static Method getPerTypeWithinAspectOf(Class aspectClass) throws NoSuchMethodException { - Method method = aspectClass.getDeclaredMethod(ASPECTOF, PERTYPEWITHIN_CLASS_ARRAY); - return checkAspectOf(method, aspectClass); - } - - private static Method checkAspectOf(Method method, Class aspectClass) throws NoSuchMethodException { - method.setAccessible(true); - if (!method.isAccessible() - || !Modifier.isPublic(method.getModifiers()) - || !Modifier.isStatic(method.getModifiers())) { - throw new NoSuchMethodException(aspectClass.getName() + ".aspectOf(..) is not accessible public static"); - } - return method; - } - - // -- hasAspect - - private static Method getSingletonOrThreadHasAspect(Class aspectClass) throws NoSuchMethodException { - Method method = aspectClass.getDeclaredMethod(HASASPECT, EMPTY_CLASS_ARRAY); - return checkHasAspect(method, aspectClass); - } - - private static Method getPerObjectHasAspect(Class aspectClass) throws NoSuchMethodException { - Method method = aspectClass.getDeclaredMethod(HASASPECT, PEROBJECT_CLASS_ARRAY); - return checkHasAspect(method, aspectClass); - } - - private static Method getPerTypeWithinHasAspect(Class aspectClass) throws NoSuchMethodException { - Method method = aspectClass.getDeclaredMethod(HASASPECT, PERTYPEWITHIN_CLASS_ARRAY); - return checkHasAspect(method, aspectClass); - } - - private static Method checkHasAspect(Method method, Class aspectClass) throws NoSuchMethodException { - method.setAccessible(true); - if (!method.isAccessible() - || !Modifier.isPublic(method.getModifiers()) - || !Modifier.isStatic(method.getModifiers())) { - throw new NoSuchMethodException(aspectClass.getName() + ".hasAspect(..) is not accessible public static"); - } - return method; - } -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/annotation/AdviceName.java b/aspectj5rt/java5-src/org/aspectj/lang/annotation/AdviceName.java deleted file mode 100644 index 779e7fee6..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/annotation/AdviceName.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer initial implementation - *******************************************************************************/ -package org.aspectj.lang.annotation; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -/** - * Used to annotated code-style advice to name it - * Name is used by reflection api if present, may in future be used in adviceexecution() pcd. - * It is an error to use the @AdviceName annotation on an annotation-style advice declaration. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface AdviceName { - - /** - * The name of the advice - */ - String value(); -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/annotation/After.java b/aspectj5rt/java5-src/org/aspectj/lang/annotation/After.java deleted file mode 100644 index 286f9c7e5..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/annotation/After.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * initial implementation Alexandre Vasseur - *******************************************************************************/ -package org.aspectj.lang.annotation; - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * After finally advice - * - * @author Alexandre Vasseur - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface After { - - /** - * The pointcut expression where to bind the advice - */ - String value(); - - /** - * When compiling without debug info, or when interpreting pointcuts at runtime, - * the names of any arguments used in the advice declaration are not available. - * Under these circumstances only, it is necessary to provide the arg names in - * the annotation - these MUST duplicate the names used in the annotated method. - * Format is a simple comma-separated list. - */ - String argNames() default ""; -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/annotation/AfterReturning.java b/aspectj5rt/java5-src/org/aspectj/lang/annotation/AfterReturning.java deleted file mode 100644 index 397c48fc6..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/annotation/AfterReturning.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * initial implementation Alexandre Vasseur - *******************************************************************************/ -package org.aspectj.lang.annotation; - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * After returning advice - * - * @author Alexandre Vasseur - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface AfterReturning { - - /** - * The pointcut expression where to bind the advice - */ - String value() default ""; - - /** - * The pointcut expression where to bind the advice, overrides "value" when specified - */ - String pointcut() default ""; - - /** - * The name of the argument in the advice signature to bind the returned value to - */ - String returning() default ""; - - /** - * When compiling without debug info, or when interpreting pointcuts at runtime, - * the names of any arguments used in the advice declaration are not available. - * Under these circumstances only, it is necessary to provide the arg names in - * the annotation - these MUST duplicate the names used in the annotated method. - * Format is a simple comma-separated list. - */ - String argNames() default ""; - -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/annotation/AfterThrowing.java b/aspectj5rt/java5-src/org/aspectj/lang/annotation/AfterThrowing.java deleted file mode 100644 index 7b4d8212c..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/annotation/AfterThrowing.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * initial implementation Alexandre Vasseur - *******************************************************************************/ -package org.aspectj.lang.annotation; - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * After throwing advice - * - * @author Alexandre Vasseur - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface AfterThrowing { - - /** - * The pointcut expression where to bind the advice - */ - String value() default ""; - - /** - * The pointcut expression where to bind the advice, overrides "value" when specified - */ - String pointcut() default ""; - - /** - * The name of the argument in the advice signature to bind the thrown exception to - */ - String throwing() default ""; - - /** - * When compiling without debug info, or when interpreting pointcuts at runtime, - * the names of any arguments used in the advice declaration are not available. - * Under these circumstances only, it is necessary to provide the arg names in - * the annotation - these MUST duplicate the names used in the annotated method. - * Format is a simple comma-separated list. - */ - String argNames() default ""; - -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/annotation/Around.java b/aspectj5rt/java5-src/org/aspectj/lang/annotation/Around.java deleted file mode 100644 index 253e865f6..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/annotation/Around.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * initial implementation Alexandre Vasseur - *******************************************************************************/ -package org.aspectj.lang.annotation; - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * Around advice - * - * @author Alexandre Vasseur - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface Around { - - /** - * The pointcut expression where to bind the advice - */ - String value(); - - /** - * When compiling without debug info, or when interpreting pointcuts at runtime, - * the names of any arguments used in the advice declaration are not available. - * Under these circumstances only, it is necessary to provide the arg names in - * the annotation - these MUST duplicate the names used in the annotated method. - * Format is a simple comma-separated list. - */ - String argNames() default ""; - -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/annotation/Aspect.java b/aspectj5rt/java5-src/org/aspectj/lang/annotation/Aspect.java deleted file mode 100644 index d45e85c84..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/annotation/Aspect.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * initial implementation Alexandre Vasseur - *******************************************************************************/ -package org.aspectj.lang.annotation; - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * Aspect declaration - * - * @author Alexandre Vasseur - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface Aspect { - - /** - * Per clause expression, defaults to singleton aspect - *

    - * Valid values are "" (singleton), "perthis(...)", etc - */ - public String value() default ""; -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/annotation/Before.java b/aspectj5rt/java5-src/org/aspectj/lang/annotation/Before.java deleted file mode 100644 index fe4b372c1..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/annotation/Before.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * initial implementation Alexandre Vasseur - *******************************************************************************/ -package org.aspectj.lang.annotation; - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * Before advice - * - * @author Alexandre Vasseur - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface Before { - - /** - * The pointcut expression where to bind the advice - */ - String value(); - - /** - * When compiling without debug info, or when interpreting pointcuts at runtime, - * the names of any arguments used in the advice declaration are not available. - * Under these circumstances only, it is necessary to provide the arg names in - * the annotation - these MUST duplicate the names used in the annotated method. - * Format is a simple comma-separated list. - */ - String argNames() default ""; - -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareAnnotation.java b/aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareAnnotation.java deleted file mode 100644 index ffecb91a2..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareAnnotation.java +++ /dev/null @@ -1,31 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Alexandre Vasseur initial implementation - *******************************************************************************/ -package org.aspectj.lang.annotation; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; - -/** - * @author Alexandre Vasseur - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR}) -public @interface DeclareAnnotation { - - /** - * pointcut (type pattern for type, or method/ctor/field signature pattern) - */ - public String value(); - -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareError.java b/aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareError.java deleted file mode 100644 index 9f3a045ee..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareError.java +++ /dev/null @@ -1,33 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.lang.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * @author colyer - * Annotation for declare error... - * - * usage: @DeclareError("somePcut()") - * private static final String "a message"; - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface DeclareError { - /** - * The pointcut expression where to bind the error (don't use if, formal bindings, cflow etc) - */ - String value(); -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareMixin.java b/aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareMixin.java deleted file mode 100644 index f44c68195..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareMixin.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * initial implementation Andy Clement - *******************************************************************************/ -package org.aspectj.lang.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * DeclareMixin annotation - see design and usage in https://bugs.eclipse.org/bugs/show_bug.cgi?id=266552 - * - *

    - * Attached to a factory method, this annotation indicates that any types matching the pattern specified in the annotation value - * will have new methods mixed in. The methods will be selected based on a combination of the return type of the factory method, - * possibly sub-setted by any list of interfaces specified in the interfaces annotation value. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface DeclareMixin { - - /** - * The target types expression - */ - String value(); - - /** - * Array of interfaces that are to be mixed in. This is optional and if not specified the return type of the annotated method - * will be used to determine the interface to mix in. - */ - Class[] interfaces() default { Object.class }; - -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareParents.java b/aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareParents.java deleted file mode 100644 index b7c2452e2..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareParents.java +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * initial implementation Adrian Colyer - *******************************************************************************/ -package org.aspectj.lang.annotation; - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * Declare parents mixin annotation - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface DeclareParents { - - /** - * The target types expression - */ - String value(); - - /** - * Optional class defining default implementation - * of interface members (equivalent to defining - * a set of interface member ITDs for the - * public methods of the interface). - */ - Class defaultImpl() default DeclareParents.class; - - // note - a default of "null" is not allowed, - // hence the strange default given above. -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclarePrecedence.java b/aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclarePrecedence.java deleted file mode 100644 index e1a048819..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclarePrecedence.java +++ /dev/null @@ -1,33 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * initial implementation Alexandre Vasseur - *******************************************************************************/ -package org.aspectj.lang.annotation; - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * Aspect precedence declaration - * - * @author Alexandre Vasseur - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface DeclarePrecedence { - - /** - * The precedence pattern list - */ - String value(); - -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareWarning.java b/aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareWarning.java deleted file mode 100644 index 446ac786a..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/annotation/DeclareWarning.java +++ /dev/null @@ -1,33 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.lang.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * @author colyer - * Annotation for declare warning... - * - * usage: @DeclareWarning("somePcut()") - * private static final String "a message"; - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface DeclareWarning { - /** - * The pointcut expression where to bind the error (don't use if, formal bindings, cflow etc) - */ - String value(); -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/annotation/Pointcut.java b/aspectj5rt/java5-src/org/aspectj/lang/annotation/Pointcut.java deleted file mode 100644 index 6fae1e8b9..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/annotation/Pointcut.java +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * initial implementation Alexandre Vasseur - *******************************************************************************/ -package org.aspectj.lang.annotation; - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * Pointcut declaration - * - * @author Alexandre Vasseur - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface Pointcut { - - /** - * The pointcut expression - * We allow "" as default for abstract pointcut - */ - String value() default ""; - - /** - * When compiling without debug info, or when interpreting pointcuts at runtime, - * the names of any arguments used in the pointcut are not available. - * Under these circumstances only, it is necessary to provide the arg names in - * the annotation - these MUST duplicate the names used in the annotated method. - * Format is a simple comma-separated list. - */ - String argNames() default ""; -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/annotation/RequiredTypes.java b/aspectj5rt/java5-src/org/aspectj/lang/annotation/RequiredTypes.java deleted file mode 100644 index d83b1bb73..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/annotation/RequiredTypes.java +++ /dev/null @@ -1,30 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2014 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * ******************************************************************/ -package org.aspectj.lang.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Can be specified on an aspect to ensure that particular types must be accessible before - * the aspect will be 'activated'. The array value should be a list of fully qualified - * type names as strings, for example "com.foo.Bar". Useful in an aspect library that - * includes a number of aspects, only a few of which should ever be active depending - * upon what is on the classpath. - * - * @author Andy Clement - * @since 1.8.3 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface RequiredTypes { - String[] value(); -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/annotation/SuppressAjWarnings.java b/aspectj5rt/java5-src/org/aspectj/lang/annotation/SuppressAjWarnings.java deleted file mode 100644 index 8fa9c6a16..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/annotation/SuppressAjWarnings.java +++ /dev/null @@ -1,31 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Wes Isberg initial implementation - * Andy Clement fleshed out to match SuppressWarnings - * ******************************************************************/ - - -package org.aspectj.lang.annotation; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * Annotate members to avoid AspectJ error messages. - * Currently supported: - *

      - *
    • advice that might not run (-Xlint TODO message id)
    • - *
    - * - */ -@Retention(RetentionPolicy.RUNTIME) -public @interface SuppressAjWarnings { - String[] value() default ""; -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/annotation/control/CodeGenerationHint.java b/aspectj5rt/java5-src/org/aspectj/lang/annotation/control/CodeGenerationHint.java deleted file mode 100644 index 7fe9dea24..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/annotation/control/CodeGenerationHint.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * initial implementation Andy Clement - *******************************************************************************/ -package org.aspectj.lang.annotation.control; - -import java.lang.annotation.Target; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * Provide code generation hints to the compiler (e.g. names to use for generated members). - * - * @author Andy Clement - */ -@Retention(RetentionPolicy.SOURCE) -@Target(ElementType.METHOD) -public @interface CodeGenerationHint { - - /** - * Defines the name suffix to use for a generated member representing an if pointcut (prefix will be 'ajc$if$'). - * If left blank, a suffix will be generated. - */ - String ifNameSuffix() default ""; - -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/reflect/Advice.java b/aspectj5rt/java5-src/org/aspectj/lang/reflect/Advice.java deleted file mode 100644 index 03be6c7f1..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/reflect/Advice.java +++ /dev/null @@ -1,59 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.lang.reflect; - -import java.lang.reflect.Type; - -/** - * Runtime representation of an advice declaration inside an aspect - */ -public interface Advice { - - /** - * The declaring aspect - */ - AjType getDeclaringType(); - - /** - * The kind of advice (before, after-returning, after-throwing, etc.) - */ - AdviceKind getKind(); - - /** - * Returns the advice name, or the empty string if the advice is anonymous. - * If using the @AspectJ annotations, the advice name is the name of the - * annotated advice method. If using the code style, the advice is - * anonymous, unless the advice is annotated with the @AdviceName annotation, - * in which case the name given in the annotation is returned. - */ - String getName(); - - /** - * The advice parameters - */ - AjType[] getParameterTypes(); - - /** - * The generic parameter types, @see java.lang.reflect.Method.getGenericParameterTypes - */ - Type[] getGenericParameterTypes(); - - /** - * The declared thrown exceptions by the advice - */ - AjType[] getExceptionTypes(); - - /** - * The pointcut expression associated with the advice declaration. - */ - PointcutExpression getPointcutExpression(); -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/reflect/AdviceKind.java b/aspectj5rt/java5-src/org/aspectj/lang/reflect/AdviceKind.java deleted file mode 100644 index 82351db88..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/reflect/AdviceKind.java +++ /dev/null @@ -1,23 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.lang.reflect; - -/** - * The different kinds of advice in AspectJ - */ -public enum AdviceKind { - BEFORE, - AFTER, - AFTER_RETURNING, - AFTER_THROWING, - AROUND; -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/reflect/AjType.java b/aspectj5rt/java5-src/org/aspectj/lang/reflect/AjType.java deleted file mode 100644 index 5e26a7d27..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/reflect/AjType.java +++ /dev/null @@ -1,380 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.lang.reflect; - -import java.lang.reflect.AnnotatedElement; -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.lang.reflect.Type; -import java.lang.reflect.TypeVariable; - -/** - * The runtime representation of a type (Aspect, Class, Interface, Annotation, Enum, or Array) in an AspectJ - * program. - */ -public interface AjType extends Type, AnnotatedElement { - - /** - * The name of this type, in the same format as returned by Class.getName() - */ - public String getName(); - - /** - * The package in which this type is declared - */ - public Package getPackage(); - - /** - * The interfaces implemented by this type - */ - public AjType[] getInterfaces(); - - /** - * The modifiers declared for this type. The return value can be interpreted - * using java.lang.reflect.Modifier - */ - public int getModifiers(); - - /** - * The java.lang.Class that corresponds to this AjType - */ - public Class getJavaClass(); - - // scope - - /** - * The supertype of this type. If this type represents Object or a primitive type - * then null is returned. - */ - public AjType getSupertype(); - - /** - * The generic supertype of this type, as defined by Class.getGenericSupertype - */ - public Type getGenericSupertype(); - - /** - * If this type represents a local or anonymous type declared within a method, return - * then enclosing Method object. - */ - public Method getEnclosingMethod(); - - /** - * If this type represents a local or anonymous type declared within a constructor, return - * then enclosing Method object. - */ - public Constructor getEnclosingConstructor(); - - /** - * Returns the immediately enclosing type of this type. - */ - public AjType getEnclosingType(); - - /** - * If this type is a member of another type, return the AjType representing the type - * in which it was declared. - */ - public AjType getDeclaringType(); - - /** - * If this type represents an aspect, returns the associated per-clause. - * Returns null for non-aspect types. - */ - public PerClause getPerClause(); - - // inner types - /** - * Returns an array containing all the public types that are members of this type - */ - public AjType[] getAjTypes(); - - /** - * Returns an array containing all the types declared by this type - */ - public AjType[] getDeclaredAjTypes(); - - // constructors - - /** - * Returns the constructor object for the specified public constructor of this type - */ - public Constructor getConstructor(AjType... parameterTypes) throws NoSuchMethodException; - - /** - * Returns all of the public constructors of this type - */ - public Constructor[] getConstructors(); - - /** - * Returns the constructor object for the specified constructor of this type - */ - public Constructor getDeclaredConstructor(AjType... parameterTypes) throws NoSuchMethodException; - - /** - * Returns all the constructors declared in this type - */ - public Constructor[] getDeclaredConstructors(); - - // fields - - /** - * Return the field declared in this type with the given name - */ - public Field getDeclaredField(String name) throws NoSuchFieldException; - - /** - * Returns all the fields declared in this type - */ - public Field[] getDeclaredFields(); - - /** - * Return the public field with the given name - */ - public Field getField(String name) throws NoSuchFieldException; - - /** - * Return the public fields declared by this type - */ - public Field[] getFields(); - - // methods - - /** - * Return the method object for the specified method declared in this type - */ - public Method getDeclaredMethod(String name, AjType... parameterTypes) throws NoSuchMethodException; - - /** - * Return the method object for the specified public method declared in this type - */ - public Method getMethod(String name, AjType... parameterTypes) throws NoSuchMethodException; - - /** - * Return all the methods declared by this type - */ - public Method[] getDeclaredMethods(); - - /** - * Returns all the public methods of this type - */ - public Method[] getMethods(); - - // pointcuts - - /** - * Return the pointcut object representing the specified pointcut declared by this type - */ - public Pointcut getDeclaredPointcut(String name) throws NoSuchPointcutException; - - /** - * Return the pointcut object representing the specified public pointcut - */ - public Pointcut getPointcut(String name) throws NoSuchPointcutException; - - /** - * Returns all of the pointcuts declared by this type - */ - public Pointcut[] getDeclaredPointcuts(); - - /** - * Returns all of the public pointcuts of this type - */ - public Pointcut[] getPointcuts(); - - // advice - - /** - * Returns all of the advice declared by this type, of an advice kind contained in the - * parameter list. - */ - public Advice[] getDeclaredAdvice(AdviceKind... ofTypes); - - /** - * Returns all of the advice for this type, of an advice kind contained in the parameter - * list. - */ - public Advice[] getAdvice(AdviceKind... ofTypes); - - /** - * Returns the advice with the given name. For an @AspectJ declared advice member, - * this is the name of the annotated method. For a code-style advice declaration, this - * is the name given in the @AdviceName annotation if present. - */ - public Advice getAdvice(String name) throws NoSuchAdviceException; - - /** - * Returns the advice declared in this type with the given name. For an @AspectJ declared advice member, - * this is the name of the annotated method. For a code-style advice declaration, this - * is the name given in the @AdviceName annotation if present. - */ - public Advice getDeclaredAdvice(String name) throws NoSuchAdviceException; - - // inter-type declarations - - /** - * Return the inter-type method declared by this type matching the given specification - */ - public InterTypeMethodDeclaration getDeclaredITDMethod(String name, AjType target, AjType... parameterTypes) throws NoSuchMethodException; - - /** - * Return all of the inter-type methods declared by this type - */ - public InterTypeMethodDeclaration[] getDeclaredITDMethods(); - - /** - * Return the public inter-type method of this type matching the given specification - */ - public InterTypeMethodDeclaration getITDMethod(String name, AjType target, AjType... parameterTypes) throws NoSuchMethodException; - - /** - * Return all of the public inter-type declared methods of this type - */ - public InterTypeMethodDeclaration[] getITDMethods(); - - /** - * Return the inter-type constructor declared by this type matching the given specification - */ - public InterTypeConstructorDeclaration getDeclaredITDConstructor(AjType target, AjType... parameterTypes) throws NoSuchMethodException; - - /** - * Returns all of the inter-type constructors declared by this type - */ - public InterTypeConstructorDeclaration[] getDeclaredITDConstructors(); - - /** - * Return the public inter-type constructor matching the given specification - */ - public InterTypeConstructorDeclaration getITDConstructor(AjType target, AjType... parameterTypes) throws NoSuchMethodException; - - /** - * Return all of the public inter-type constructors of this type - */ - public InterTypeConstructorDeclaration[] getITDConstructors(); - - /** - * Return the inter-type field declared in this type with the given specification - */ - public InterTypeFieldDeclaration getDeclaredITDField(String name, AjType target) throws NoSuchFieldException; - - /** - * Return all of the inter-type fields declared in this type - */ - public InterTypeFieldDeclaration[] getDeclaredITDFields(); - - /** - * Return the public inter-type field matching the given specification - */ - public InterTypeFieldDeclaration getITDField(String name, AjType target) throws NoSuchFieldException; - - /** - * Return all of the public inter-type fields for this type - */ - public InterTypeFieldDeclaration[] getITDFields(); - - // declare statements - /** - * Returns all of the declare error and declare warning members of this type, - * including declare error/warning members inherited from super-types - */ - public DeclareErrorOrWarning[] getDeclareErrorOrWarnings(); - - /** - * Returns all of the declare parents members of this type, including - * declare parent members inherited from super-types - */ - public DeclareParents[] getDeclareParents(); - - /** - * Return all of the declare soft members of this type, including declare - * soft members inherited from super-types - */ - public DeclareSoft[] getDeclareSofts(); - - /** - * Return all of the declare annotation members of this type, including declare - * annotation members inherited from super-types - */ - public DeclareAnnotation[] getDeclareAnnotations(); - - /** - * Return all of the declare precedence members of this type, including declare - * precedence members inherited from super-types - */ - public DeclarePrecedence[] getDeclarePrecedence(); - - // misc - - /** - * Returns the elements of this enum class, or null if this type does not represent - * an enum type. - */ - public T[] getEnumConstants(); - - /** - * Returns an array of TypeVariable objects that represent the type variables declared by - * this type (if any) - */ - public TypeVariable>[] getTypeParameters(); - - /** - * True if this is an enum type - */ - public boolean isEnum(); - - /** - * True if the given object is assignment-compatible with an object of the type represented - * by this AjType - */ - public boolean isInstance(Object o); - - /** - * True if this is an interface type - */ - public boolean isInterface(); - - /** - * Returns true if and only if the underlying type is a local class - */ - public boolean isLocalClass(); - - /** - * Returns true if and only if the underlying type is a member class - */ - public boolean isMemberClass(); - - /** - * Return true if this is an array type - */ - public boolean isArray(); - - /** - * Return true if this object represents a primitive type - */ - public boolean isPrimitive(); - - /** - * Return true if this is an aspect type - */ - public boolean isAspect(); - - /** - * Returns true if and only if the underlying type is a member aspect - */ - public boolean isMemberAspect(); - - /** - * Returns true if and only if the underlying type is a privileged aspect - */ - public boolean isPrivileged(); - -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/reflect/AjTypeSystem.java b/aspectj5rt/java5-src/org/aspectj/lang/reflect/AjTypeSystem.java deleted file mode 100644 index 6999dac19..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/reflect/AjTypeSystem.java +++ /dev/null @@ -1,55 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.lang.reflect; - -import java.lang.ref.WeakReference; -import java.util.Collections; -import java.util.Map; -import java.util.WeakHashMap; - -import org.aspectj.internal.lang.reflect.AjTypeImpl; - -/** - * This is the anchor for the AspectJ runtime type system. - * Typical usage to get the AjType representation of a given type - * at runtime is to call AjType fooType = AjTypeSystem.getAjType(Foo.class); - */ -public class AjTypeSystem { - - private static Map> ajTypes = - Collections.synchronizedMap(new WeakHashMap>()); - - /** - * Return the AspectJ runtime type representation of the given Java type. - * Unlike java.lang.Class, AjType understands pointcuts, advice, declare statements, - * and other AspectJ type members. AjType is the recommended reflection API for - * AspectJ programs as it offers everything that java.lang.reflect does, with - * AspectJ-awareness on top. - */ - public static AjType getAjType(Class fromClass) { - WeakReference weakRefToAjType = ajTypes.get(fromClass); - if (weakRefToAjType!=null) { - AjType theAjType = weakRefToAjType.get(); - if (theAjType != null) { - return theAjType; - } else { - theAjType = new AjTypeImpl(fromClass); - ajTypes.put(fromClass, new WeakReference(theAjType)); - return theAjType; - } - } - // neither key nor value was found - AjType theAjType = new AjTypeImpl(fromClass); - ajTypes.put(fromClass, new WeakReference(theAjType)); - return theAjType; - } -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/reflect/DeclareAnnotation.java b/aspectj5rt/java5-src/org/aspectj/lang/reflect/DeclareAnnotation.java deleted file mode 100644 index faee5d495..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/reflect/DeclareAnnotation.java +++ /dev/null @@ -1,56 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.lang.reflect; - -import java.lang.annotation.Annotation; - -/** - * The AspectJ runtime representation of a declare annotation member in an aspect. - * - */ -public interface DeclareAnnotation { - - public enum Kind { Field, Method, Constructor, Type }; - - /** - * The aspect that declared this member. - */ - AjType getDeclaringType(); - - /** - * The target element kind - */ - Kind getKind(); - - /** - * The target signature pattern. Returns null if getKind() == Type - */ - SignaturePattern getSignaturePattern(); - - /** - * The target type pattern. Returns null if getKind() != Type - */ - TypePattern getTypePattern(); - - /** - * The declared annotation. If the declared annotation does not have runtime retention, - * this method returns null. - */ - Annotation getAnnotation(); - - /** - * Returns the text of the annotation as declared in this member. Available for - * both runtime and class-file retention annotations - */ - String getAnnotationAsText(); - -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/reflect/DeclareErrorOrWarning.java b/aspectj5rt/java5-src/org/aspectj/lang/reflect/DeclareErrorOrWarning.java deleted file mode 100644 index a6a5abc53..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/reflect/DeclareErrorOrWarning.java +++ /dev/null @@ -1,40 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.lang.reflect; - -/** - * AspectJ runtime representation of a declare error or declare warning member - * in an aspect. - */ -public interface DeclareErrorOrWarning { - - /** - * The type that declared this declare warning or declare error member. - */ - AjType getDeclaringType(); - - /** - * The pointcut expression associated with the warning or error - */ - PointcutExpression getPointcutExpression(); - - /** - * The message associated with the declare warning / declare error - */ - String getMessage(); - - /** - * True if this is a declare error member, false if it is declare warning - */ - boolean isError(); - -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/reflect/DeclareParents.java b/aspectj5rt/java5-src/org/aspectj/lang/reflect/DeclareParents.java deleted file mode 100644 index 8d3c98b78..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/reflect/DeclareParents.java +++ /dev/null @@ -1,47 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.lang.reflect; - -import java.lang.reflect.Type; - -/** - * A declare parents member defined inside an aspect - */ -public interface DeclareParents { - - /** - * The declaring aspect - */ - AjType getDeclaringType(); - - /** - * The target type pattern - */ - TypePattern getTargetTypesPattern(); - - /** - * True if this is a declare parents...extends member declaration - */ - boolean isExtends(); - - /** - * True if this is a declare parents...implements member declaration - */ - boolean isImplements(); - - /** - * The set of types that the types matching getTargetTypesPattern are - * declared to implement or extend - */ - Type[] getParentTypes() throws ClassNotFoundException; - -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/reflect/DeclarePrecedence.java b/aspectj5rt/java5-src/org/aspectj/lang/reflect/DeclarePrecedence.java deleted file mode 100644 index 894580b70..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/reflect/DeclarePrecedence.java +++ /dev/null @@ -1,32 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.lang.reflect; - -/** - * AspectJ runtime representation of a declare precedence statement as - * declared in an aspect. - */ -public interface DeclarePrecedence { - - /** - * The declaring aspect - */ - AjType getDeclaringType(); - - /** - * Returns an ordered set of type patterns. An aspect matching - * a type pattern at a lower index in the array takes precedence - * over an aspect that only matches a type pattern at a higher - * index in the array. - */ - TypePattern[] getPrecedenceOrder(); -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/reflect/DeclareSoft.java b/aspectj5rt/java5-src/org/aspectj/lang/reflect/DeclareSoft.java deleted file mode 100644 index cc607d680..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/reflect/DeclareSoft.java +++ /dev/null @@ -1,34 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.lang.reflect; - -/** - * AspectJ runtime representation of a declare soft member within an aspect. - */ -public interface DeclareSoft { - - /** - * The aspect that declared this member - */ - AjType getDeclaringType(); - - /** - * The softened exception type - */ - AjType getSoftenedExceptionType() throws ClassNotFoundException; - - /** - * The pointcut determining the join points at which the exception is to be softened. - */ - PointcutExpression getPointcutExpression(); - -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/reflect/InterTypeConstructorDeclaration.java b/aspectj5rt/java5-src/org/aspectj/lang/reflect/InterTypeConstructorDeclaration.java deleted file mode 100644 index 8db4505e3..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/reflect/InterTypeConstructorDeclaration.java +++ /dev/null @@ -1,36 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.lang.reflect; - -import java.lang.reflect.Type; - -/** - * Runtime representation of an inter-type constructor member declared within an - * aspect. - */ -public interface InterTypeConstructorDeclaration extends InterTypeDeclaration { - - /** - * The constructor parameters - */ - AjType[] getParameterTypes(); - - /** - * The generic constructor parameters - */ - Type[] getGenericParameterTypes(); - - /** - * The declared exceptions thrown by this constructor - */ - AjType[] getExceptionTypes(); -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/reflect/InterTypeDeclaration.java b/aspectj5rt/java5-src/org/aspectj/lang/reflect/InterTypeDeclaration.java deleted file mode 100644 index c00461011..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/reflect/InterTypeDeclaration.java +++ /dev/null @@ -1,33 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.lang.reflect; - -/** - * Represents an inter-type method, field, or constructor declared in an aspect. - */ -public interface InterTypeDeclaration { - - /** - * The declaring aspect - */ - AjType getDeclaringType(); - - /** - * The target type of this ITD - */ - AjType getTargetType() throws ClassNotFoundException; - - /** - * Member modifiers, can be interpreted using java.lang.reflect.Modifier - */ - int getModifiers(); -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/reflect/InterTypeFieldDeclaration.java b/aspectj5rt/java5-src/org/aspectj/lang/reflect/InterTypeFieldDeclaration.java deleted file mode 100644 index 5a8acd76c..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/reflect/InterTypeFieldDeclaration.java +++ /dev/null @@ -1,36 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.lang.reflect; - -import java.lang.reflect.Type; - -/** - * Represents an inter-type field declaration declared in an aspect. - */ -public interface InterTypeFieldDeclaration extends InterTypeDeclaration { - - /** - * The field name - */ - String getName(); - - /** - * The field type - */ - AjType getType(); - - /** - * The generic field type - */ - Type getGenericType(); - -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/reflect/InterTypeMethodDeclaration.java b/aspectj5rt/java5-src/org/aspectj/lang/reflect/InterTypeMethodDeclaration.java deleted file mode 100644 index e570d8d2d..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/reflect/InterTypeMethodDeclaration.java +++ /dev/null @@ -1,57 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.lang.reflect; - -import java.lang.reflect.Method; -import java.lang.reflect.Type; -import java.lang.reflect.TypeVariable; - -/** - * Represents an inter-type method declaration member within an aspect. - */ -public interface InterTypeMethodDeclaration extends InterTypeDeclaration { - - /** - * The name of this method - */ - String getName(); - - /** - * The method return type - */ - AjType getReturnType(); - - /** - * The generic return type - */ - Type getGenericReturnType(); - - /** - * The method parameters - */ - AjType[] getParameterTypes(); - - /** - * The generic method parameters - */ - Type[] getGenericParameterTypes(); - - /** - * The type variables declared by this method - */ - TypeVariable[] getTypeParameters(); - - /** - * The declared exceptions thrown by this method - */ - AjType[] getExceptionTypes(); -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/reflect/NoSuchAdviceException.java b/aspectj5rt/java5-src/org/aspectj/lang/reflect/NoSuchAdviceException.java deleted file mode 100644 index 6b1ca8fa0..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/reflect/NoSuchAdviceException.java +++ /dev/null @@ -1,34 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.lang.reflect; - -/** - * Thrown when AjType.getDeclaredAdvice is called with an advice name and no matching - * advice declaration can be found. - */ -public class NoSuchAdviceException extends Exception { - - private static final long serialVersionUID = 3256444698657634352L; - private String name; - - public NoSuchAdviceException(String name) { - this.name = name; - } - - /** - * The advice name that could not be found. - */ - public String getName() { - return name; - } - -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/reflect/NoSuchPointcutException.java b/aspectj5rt/java5-src/org/aspectj/lang/reflect/NoSuchPointcutException.java deleted file mode 100644 index 0274b74b4..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/reflect/NoSuchPointcutException.java +++ /dev/null @@ -1,34 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.lang.reflect; - -/** - * Thrown when AjType.getDeclaredPointcut is called with a pointcut name, and no - * matching pointcut declaration can be found. - */ -public class NoSuchPointcutException extends Exception { - - private static final long serialVersionUID = 3256444698657634352L; - private String name; - - public NoSuchPointcutException(String name) { - this.name = name; - } - - /** - * The name of the pointcut that could not be found. - */ - public String getName() { - return name; - } - -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/reflect/PerClause.java b/aspectj5rt/java5-src/org/aspectj/lang/reflect/PerClause.java deleted file mode 100644 index c16feda33..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/reflect/PerClause.java +++ /dev/null @@ -1,23 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.lang.reflect; - -/** - * AspectJ runtime representation of the per-clause associated with an aspect. - */ -public interface PerClause { - /** - * The kind of per-clause (singleton, perthis, pertarget,...) - */ - PerClauseKind getKind(); - -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/reflect/PerClauseKind.java b/aspectj5rt/java5-src/org/aspectj/lang/reflect/PerClauseKind.java deleted file mode 100644 index 1e2d42ecd..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/reflect/PerClauseKind.java +++ /dev/null @@ -1,25 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.lang.reflect; - -/** - * The different per-clauses (aspect instantiation models) - * supported by AspectJ - */ -public enum PerClauseKind { - SINGLETON, - PERTHIS, - PERTARGET, - PERCFLOW, - PERCFLOWBELOW, - PERTYPEWITHIN; -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/reflect/Pointcut.java b/aspectj5rt/java5-src/org/aspectj/lang/reflect/Pointcut.java deleted file mode 100644 index dfec7ccbd..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/reflect/Pointcut.java +++ /dev/null @@ -1,52 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.lang.reflect; - -/** - * AspectJ runtime representation of a pointcut member inside a class or aspect. - */ -public interface Pointcut { - - /** - * The declared name of the pointcut. - */ - String getName(); - - /** - * The modifiers associated with the pointcut declaration. - * Use java.lang.reflect.Modifier to interpret the return value - */ - int getModifiers(); - - /** - * The pointcut parameter types. - */ - AjType[] getParameterTypes(); - - /** - * The pointcut parameter names. Returns an array of empty strings - * of length getParameterTypes().length if parameter names are not - * available at runtime. - */ - String[] getParameterNames(); - - /** - * The type that declared this pointcut - */ - AjType getDeclaringType(); - - /** - * The pointcut expression associated with this pointcut. - */ - PointcutExpression getPointcutExpression(); - -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/reflect/PointcutBasedPerClause.java b/aspectj5rt/java5-src/org/aspectj/lang/reflect/PointcutBasedPerClause.java deleted file mode 100644 index db040ea62..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/reflect/PointcutBasedPerClause.java +++ /dev/null @@ -1,25 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.lang.reflect; - -/** - * Representation of a pointcut based per-clause associated with an aspect - * (perthis/target/cflow/cflowbelow) - * - */ -public interface PointcutBasedPerClause extends PerClause { - - /** - * Get the associated pointcut expression - */ - PointcutExpression getPointcutExpression(); -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/reflect/PointcutExpression.java b/aspectj5rt/java5-src/org/aspectj/lang/reflect/PointcutExpression.java deleted file mode 100644 index e229ba1f0..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/reflect/PointcutExpression.java +++ /dev/null @@ -1,24 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.lang.reflect; - -/** - * Represents an anonymous pointcut expression as used in pointcuts, advice declarations, - * declares, and per-clauses - */ -public interface PointcutExpression { - - /** - * Returns a String representation of the pointcut expression - */ - String asString(); -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/reflect/SignaturePattern.java b/aspectj5rt/java5-src/org/aspectj/lang/reflect/SignaturePattern.java deleted file mode 100644 index 99ba44dda..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/reflect/SignaturePattern.java +++ /dev/null @@ -1,23 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.lang.reflect; - -/** - * AspectJ runtime representation of a signature pattern as used in various - * aspect members (for example, declare @method, declare @field). - */ -public interface SignaturePattern { - - /** return a String representation of this pattern */ - String asString(); - -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/reflect/TypePattern.java b/aspectj5rt/java5-src/org/aspectj/lang/reflect/TypePattern.java deleted file mode 100644 index f3b69b421..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/reflect/TypePattern.java +++ /dev/null @@ -1,22 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.lang.reflect; - -/** - * AspectJ runtime representation of a type pattern as used in member declarations - * such as declare parents. - */ -public interface TypePattern { - - /** a string representation of the pattern */ - String asString(); -} diff --git a/aspectj5rt/java5-src/org/aspectj/lang/reflect/TypePatternBasedPerClause.java b/aspectj5rt/java5-src/org/aspectj/lang/reflect/TypePatternBasedPerClause.java deleted file mode 100644 index 402b883b9..000000000 --- a/aspectj5rt/java5-src/org/aspectj/lang/reflect/TypePatternBasedPerClause.java +++ /dev/null @@ -1,26 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.lang.reflect; - -/** - * AspectJ runtime representation of a type pattern based per-clause associated - * with an aspect (pertypewithin). - * - */ -public interface TypePatternBasedPerClause { - - /** - * Get the associated type pattern - */ - TypePattern getTypePattern(); - -} diff --git a/aspectj5rt/java5-testsrc/Aspectj5rt15ModuleTests.java b/aspectj5rt/java5-testsrc/Aspectj5rt15ModuleTests.java deleted file mode 100644 index c1d54dc67..000000000 --- a/aspectj5rt/java5-testsrc/Aspectj5rt15ModuleTests.java +++ /dev/null @@ -1,34 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Wes Isberg initial implementation - * ******************************************************************/ - -// default package - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -import org.aspectj.internal.lang.reflect.AjTypeTests; -import org.aspectj.internal.lang.reflect.AjTypeTestsWithAspects; -import org.aspectj.internal.lang.reflect.InterTypeTests; - -public class Aspectj5rt15ModuleTests extends TestCase { - - public static Test suite() { - TestSuite suite = new TestSuite("Aspectj5rt module tests"); - suite.addTestSuite(AjTypeTests.class); - suite.addTestSuite(AjTypeTestsWithAspects.class); - suite.addTestSuite(InterTypeTests.class); - return suite; - } - - -} diff --git a/aspectj5rt/java5-testsrc/org/aspectj/internal/lang/reflect/AjTypeTests.java b/aspectj5rt/java5-testsrc/org/aspectj/internal/lang/reflect/AjTypeTests.java deleted file mode 100644 index 9416979de..000000000 --- a/aspectj5rt/java5-testsrc/org/aspectj/internal/lang/reflect/AjTypeTests.java +++ /dev/null @@ -1,327 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer initial implementation - * ******************************************************************/ -package org.aspectj.internal.lang.reflect; - -import java.io.Serializable; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.lang.reflect.Type; -import java.lang.reflect.TypeVariable; - -import junit.framework.TestCase; - -import org.aspectj.lang.reflect.AjType; -import org.aspectj.lang.reflect.AjTypeSystem; - -public class AjTypeTests extends TestCase { - - private AjType stringType; - - @Override - protected void setUp() throws Exception { - super.setUp(); - stringType = AjTypeSystem.getAjType(String.class); - } - - public void testCreateAjType() { - assertNotNull("should find type",stringType); - } - - public void testGetName() { - assertEquals(String.class.getName(),stringType.getName()); - } - - public void testGetPackage() { - assertEquals(String.class.getPackage(),stringType.getPackage()); - } - - public void testGetInterfaces() { - Class[] i1 = String.class.getInterfaces(); - AjType[] i2 = stringType.getInterfaces(); - assertEquals(i1.length,i2.length); - for (int i = 0; i < i1.length; i++) - assertEquals(i1[i],i2[i].getJavaClass()); - } - - public void testGetModifiers() { - assertEquals(String.class.getModifiers(),stringType.getModifiers()); - } - - public void testGetSupertype() { - Class stringSuper = String.class.getSuperclass(); - AjType ajSuper = stringType.getSupertype(); - assertEquals(AjTypeSystem.getAjType(stringSuper),ajSuper); - } - - public void testObjectSupertype() { - AjType objectSuper = AjTypeSystem.getAjType(Object.class).getSupertype(); - assertNull(objectSuper); - } - - public void testInterfaceSupertype() { - AjType serializableSuper = AjTypeSystem.getAjType(Serializable.class).getSupertype(); - assertNull(serializableSuper); - } - - public void testGetGenericSupertype() { - Type t = AjTypeSystem.getAjType(Goo.class).getGenericSupertype(); - assertEquals(Foo.class,t); - } - - public void testGetEnclosingMethod() { - new Goo().foo(); - } - - public void testGetEnclosingConstructor() { - new Goo(); - } - - public void testGetEnclosingType() { - AjType t = AjTypeSystem.getAjType(Foo.Z.class); - assertEquals("org.aspectj.internal.lang.reflect.Foo",t.getEnclosingType().getName()); - } - - public void testGetDeclaringType() { - AjType t = AjTypeSystem.getAjType(Foo.Z.class); - assertEquals("org.aspectj.internal.lang.reflect.Foo",t.getDeclaringType().getName()); - } - - public void testIsAnnotationPresent() { - AjType foo = AjTypeSystem.getAjType(Foo.class); - AjType goo = AjTypeSystem.getAjType(Goo.class); - assertTrue(foo.isAnnotationPresent(SomeAnn.class)); - assertFalse(goo.isAnnotationPresent(SomeAnn.class)); - } - - public void testGetAnnotation() { - AjType foo = AjTypeSystem.getAjType(Foo.class); - AjType goo = AjTypeSystem.getAjType(Goo.class); - assertNotNull(foo.getAnnotation(SomeAnn.class)); - assertNull(goo.getAnnotation(SomeAnn.class)); - } - - public void testGetAnnotations() { - AjType foo = AjTypeSystem.getAjType(Foo.class); - AjType goo = AjTypeSystem.getAjType(Goo.class); - assertEquals(1,foo.getAnnotations().length); - assertEquals(0,goo.getAnnotations().length); - } - - public void testGetDeclaredAnnotations() { - AjType foo = AjTypeSystem.getAjType(Foo.class); - AjType goo = AjTypeSystem.getAjType(Goo.class); - assertEquals(0,goo.getDeclaredAnnotations().length); - assertEquals(1,foo.getDeclaredAnnotations().length); - } - - public void testGetAjTypes() { - AjType foo = AjTypeSystem.getAjType(Foo.class); - AjType[] fooTypes = foo.getAjTypes(); - assertEquals(1,fooTypes.length); - assertEquals("org.aspectj.internal.lang.reflect.Foo$Z",fooTypes[0].getName()); - } - - public void testGetDeclaredAjTypes() { - AjType foo = AjTypeSystem.getAjType(Foo.class); - AjType[] fooTypes = foo.getDeclaredAjTypes(); - assertEquals(2,fooTypes.length); - // Alex -> Adrian: looks like you can not make assumption on the ordering - String s = " " + fooTypes[0].getName() + " " + fooTypes[1].getName(); - assertTrue(s.indexOf(" org.aspectj.internal.lang.reflect.Foo$Z") >= 0); - assertTrue(s.indexOf(" org.aspectj.internal.lang.reflect.Foo$XX") >= 0); - } - - public void testGetConstructor() throws Exception { - Constructor c1 = String.class.getConstructor(String.class); - Constructor c2 = stringType.getConstructor(stringType); - assertEquals(c1,c2); - } - - public void testGetConstructors() { - Constructor[] c1 = String.class.getConstructors(); - Constructor[] c2 = stringType.getConstructors(); - assertEquals(c1.length,c2.length); - for (int i = 0; i < c1.length; i++) - assertEquals(c1[i],c2[i]); - } - - public void testGetDeclaredConstructor() throws Exception { - Constructor c1 = String.class.getDeclaredConstructor(String.class); - Constructor c2 = stringType.getDeclaredConstructor(stringType); - assertEquals(c1,c2); - } - - public void testGetDeclaredConstructors() { - Constructor[] c1 = String.class.getDeclaredConstructors(); - Constructor[] c2 = stringType.getDeclaredConstructors(); - assertEquals(c1.length,c2.length); - for (int i = 0; i < c1.length; i++) - assertEquals(c1[i],c2[i]); - } - - public void testGetDeclaredField() throws Exception { - Field f1 = String.class.getDeclaredField("value"); - Field f2 = stringType.getDeclaredField("value"); - assertEquals(f1,f2); - } - - public void testGetDeclaredFields() { - Field[] f1 = String.class.getDeclaredFields(); - Field[] f2 = stringType.getDeclaredFields(); - assertEquals(f1.length,f2.length); - for (int i = 0; i < f1.length; i++) - assertEquals(f1[i],f2[i]); - } - - public void testGetField() throws Exception { - AjType goo = AjTypeSystem.getAjType(Goo.class); - assertEquals("g",goo.getField("g").getName()); - } - - public void testGetFields() { - AjType goo = AjTypeSystem.getAjType(Goo.class); - Field[] fields = goo.getFields(); - assertEquals(1,fields.length); - assertEquals("g",fields[0].getName()); - - } - - public void testGetDeclaredMethod() throws Exception { - Method m1 = String.class.getDeclaredMethod("toUpperCase"); - Method m2 = stringType.getDeclaredMethod("toUpperCase"); - assertEquals(m1,m2); - } - - public void testGetMethod() throws Exception { - Method m1 = String.class.getMethod("toUpperCase"); - Method m2 = stringType.getMethod("toUpperCase"); - assertEquals(m1,m2); - } - - public void testGetDeclaredMethods() { - Method[] m1 = String.class.getDeclaredMethods(); - Method[] m2 = stringType.getDeclaredMethods(); - assertEquals(m1.length,m2.length); - for (int i = 0; i < m1.length; i++) - assertEquals(m1[i],m2[i]); - } - - public void testGetMethods() { - Method[] m1 = String.class.getMethods(); - Method[] m2 = stringType.getMethods(); - assertEquals(m1.length,m2.length); - for (int i = 0; i < m1.length; i++) - assertEquals(m1[i],m2[i]); - } - - public void testGetEnumConstants() { - AjType e = AjTypeSystem.getAjType(E.class); - Object[] consts = e.getEnumConstants(); - assertEquals(3,consts.length); - } - - public void testGetTypeParameters() { - AjType foo = AjTypeSystem.getAjType(Foo.class); - TypeVariable>[] tvs = foo.getTypeParameters(); - assertEquals(1,tvs.length); - assertEquals("T",tvs[0].getName()); - } - - public void testIsEnum() { - assertFalse(stringType.isEnum()); - } - - public void testIsInstance() { - assertTrue(stringType.isInstance("I am")); - } - - public void testIsInterface() { - assertFalse(stringType.isInterface()); - assertTrue(AjTypeSystem.getAjType(Serializable.class).isInterface()); - } - - public void testIsLocalClass() { - assertFalse(stringType.isLocalClass()); - } - - public void testIsArray() { - assertFalse(stringType.isArray()); - assertTrue(AjTypeSystem.getAjType(Integer[].class).isArray()); - } - - public void testIsPrimitive() { - assertFalse(stringType.isPrimitive()); - assertTrue(AjTypeSystem.getAjType(boolean.class).isPrimitive()); - } - - public void testIsAspect() { - assertFalse(stringType.isAspect()); - } - - public void testIsMemberAspect() { - assertFalse(stringType.isMemberAspect()); - } - - public void testIsPrivileged() { - assertFalse(stringType.isPrivileged()); - } - - public void testEquals() { - AjType stringTypeTwo = AjTypeSystem.getAjType(String.class); - assertTrue(stringType.equals(stringTypeTwo)); - } - - public void testHashCode() { - AjType stringTypeTwo = AjTypeSystem.getAjType(String.class); - assertEquals(stringType.hashCode(),stringTypeTwo.hashCode()); - } - -} - -@Retention(RetentionPolicy.RUNTIME) -@interface SomeAnn {} - -@SomeAnn -class Foo { - - public Foo() { - class Y { int y; } - AjType t = AjTypeSystem.getAjType(Y.class); - Constructor c = t.getEnclosingConstructor(); - if (!c.getName().equals("org.aspectj.internal.lang.reflect.Foo")) throw new RuntimeException("should have been Foo"); - } - public void foo() { - class X { int x; } - AjType t = AjTypeSystem.getAjType(X.class); - Method m = t.getEnclosingMethod(); - if (!m.getName().equals("foo")) throw new RuntimeException("should have been foo"); - } - public class Z { int z; } - class XX { int xx; } -} - -class Goo extends Foo { - @interface IX {} - - public Goo() { - super(); - } - - public int g; - int g2; - -} - -enum E { A,B,C; } diff --git a/aspectj5rt/java5-testsrc/org/aspectj/internal/lang/reflect/AjTypeTestsWithAspects.java b/aspectj5rt/java5-testsrc/org/aspectj/internal/lang/reflect/AjTypeTestsWithAspects.java deleted file mode 100644 index 046733b82..000000000 --- a/aspectj5rt/java5-testsrc/org/aspectj/internal/lang/reflect/AjTypeTestsWithAspects.java +++ /dev/null @@ -1,449 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer initial implementation - * ******************************************************************/ -package org.aspectj.internal.lang.reflect; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; - -import junit.framework.TestCase; - -import org.aspectj.internal.lang.annotation.ajcDeclareEoW; -import org.aspectj.internal.lang.annotation.ajcPrivileged; -import org.aspectj.lang.annotation.AdviceName; -import org.aspectj.lang.annotation.After; -import org.aspectj.lang.annotation.AfterReturning; -import org.aspectj.lang.annotation.AfterThrowing; -import org.aspectj.lang.annotation.Around; -import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.annotation.Before; -import org.aspectj.lang.annotation.DeclareError; -import org.aspectj.lang.annotation.DeclareWarning; -import org.aspectj.lang.reflect.Advice; -import org.aspectj.lang.reflect.AdviceKind; -import org.aspectj.lang.reflect.AjType; -import org.aspectj.lang.reflect.AjTypeSystem; -import org.aspectj.lang.reflect.DeclareErrorOrWarning; -import org.aspectj.lang.reflect.NoSuchAdviceException; -import org.aspectj.lang.reflect.NoSuchPointcutException; -import org.aspectj.lang.reflect.PerClause; -import org.aspectj.lang.reflect.PerClauseKind; -import org.aspectj.lang.reflect.Pointcut; -import org.aspectj.lang.reflect.PointcutBasedPerClause; -import org.aspectj.lang.reflect.TypePatternBasedPerClause; - -public class AjTypeTestsWithAspects extends TestCase { - - private AjType sa; - - protected void setUp() throws Exception { - super.setUp(); - sa = AjTypeSystem.getAjType(SimpleAspect.class); - } - - public void testGetPerClause() { - AjType perThisA = AjTypeSystem.getAjType(PerThisAspect.class); - AjType perTargetA = AjTypeSystem.getAjType(PerTargetAspect.class); - AjType perCflowA = AjTypeSystem.getAjType(PerCflowAspect.class); - AjType perCflowbelowA = AjTypeSystem.getAjType(PerCflowbelowAspect.class); - AjType perTypeWithinA = AjTypeSystem.getAjType(PerTypeWithin.class); - - PerClause pc = perThisA.getPerClause(); - assertEquals(PerClauseKind.PERTHIS,pc.getKind()); - assertEquals("pc()",((PointcutBasedPerClause)pc).getPointcutExpression().asString()); - assertEquals("perthis(pc())",pc.toString()); - - pc= perTargetA.getPerClause(); - assertEquals(PerClauseKind.PERTARGET,pc.getKind()); - assertEquals("pc()",((PointcutBasedPerClause)pc).getPointcutExpression().asString()); - assertEquals("pertarget(pc())",pc.toString()); - - pc= perCflowA.getPerClause(); - assertEquals(PerClauseKind.PERCFLOW,pc.getKind()); - assertEquals("pc()",((PointcutBasedPerClause)pc).getPointcutExpression().asString()); - assertEquals("percflow(pc())",pc.toString()); - - pc= perCflowbelowA.getPerClause(); - assertEquals(PerClauseKind.PERCFLOWBELOW,pc.getKind()); - assertEquals("pc()",((PointcutBasedPerClause)pc).getPointcutExpression().asString()); - assertEquals("percflowbelow(pc())",pc.toString()); - - pc= perTypeWithinA.getPerClause(); - assertEquals(PerClauseKind.PERTYPEWITHIN,pc.getKind()); - assertEquals("org.aspectj..*",((TypePatternBasedPerClause)pc).getTypePattern().asString()); - assertEquals("pertypewithin(org.aspectj..*)",pc.toString()); - - } - - public void testGetDeclaredField() throws Exception{ - Field f = sa.getDeclaredField("s"); - try { - Field f2 = sa.getDeclaredField("ajc$xyz$s"); - fail("Expecting NoSuchFieldException"); - } catch (NoSuchFieldException nsf) {} - } - - public void testGetField() throws Exception { - Field f = sa.getField("s"); - try { - Field f2 = sa.getField("ajc$xyz$s"); - fail("Expecting NoSuchFieldException"); - } catch (NoSuchFieldException nsf) {} - } - - public void testGetDeclaredFields() { - Field[] fields = sa.getDeclaredFields(); - assertEquals(1,fields.length); - assertEquals("s",fields[0].getName()); - } - - public void testGetFields() { - Field[] fields = sa.getFields(); - assertEquals(1,fields.length); - assertEquals("s",fields[0].getName()); - } - - public void testGetDeclaredMethod() throws Exception { - Method m = sa.getDeclaredMethod("aMethod"); - try { - Method m2 = sa.getDeclaredMethod("logEntry"); - fail("Expecting NoSuchMethodException"); - } catch(NoSuchMethodException ex) {} - try { - Method m3 = sa.getDeclaredMethod("ajc$before$123"); - fail("Expecting NoSuchMethodException"); - } catch(NoSuchMethodException ex) {} - } - - public void testGetMethod() throws Exception { - Method m = sa.getMethod("aMethod"); - try { - Method m2 = sa.getMethod("logEntry"); - fail("Expecting NoSuchMethodException"); - } catch(NoSuchMethodException ex) {} - try { - Method m3 = sa.getMethod("ajc$before$123"); - fail("Expecting NoSuchMethodException"); - } catch(NoSuchMethodException ex) {} - } - - public void testGetDeclaredMethods() { - Method[] ms = sa.getDeclaredMethods(); - assertEquals(1,ms.length); - assertEquals("aMethod",ms[0].getName()); - } - - public void testGetMethods() { - Method[] ms = sa.getMethods(); - assertEquals(10,ms.length); - //AV was corrupted, cannot rely on ordering - String match = ""; - for (int i = 0; i < ms.length; i++) { - match = match + "--" + ms[i].getName(); - } - assertTrue(match.indexOf("aMethod") >=0); - } - - public void testGetDeclaredPointcut() throws Exception { - Pointcut p1 = sa.getDeclaredPointcut("simpleAspectMethodExecution"); - assertEquals("simpleAspectMethodExecution",p1.getName()); - assertEquals("execution(* SimpleAspect.*(..))",p1.getPointcutExpression().asString()); - assertEquals("simpleAspectMethodExecution() : execution(* SimpleAspect.*(..))",p1.toString()); - assertEquals(sa,p1.getDeclaringType()); - assertEquals(0,p1.getParameterTypes().length); - assertTrue(Modifier.isPublic(p1.getModifiers())); - Pointcut p2 = sa.getDeclaredPointcut("simpleAspectCall"); - assertEquals("simpleAspectCall",p2.getName()); - assertEquals("call(* SimpleAspect.*(..))",p2.getPointcutExpression().asString()); - assertEquals(sa,p2.getDeclaringType()); - assertEquals(1,p2.getParameterTypes().length); - assertTrue(Modifier.isPrivate(p2.getModifiers())); - try { - Pointcut p3 = sa.getDeclaredPointcut("sausages"); - fail("Expecting NoSuchPointcutExcetpion"); - } catch (NoSuchPointcutException ex) { - assertEquals("sausages",ex.getName()); - } - } - - public void testGetPointcut() throws Exception { - Pointcut p1 = sa.getPointcut("simpleAspectMethodExecution"); - assertEquals("simpleAspectMethodExecution",p1.getName()); - assertEquals("execution(* SimpleAspect.*(..))",p1.getPointcutExpression().asString()); - assertEquals(sa,p1.getDeclaringType()); - assertEquals(0,p1.getParameterTypes().length); - assertTrue(Modifier.isPublic(p1.getModifiers())); - Pointcut p2 = sa.getDeclaredPointcut("simpleAspectCall"); - assertEquals("simpleAspectCall",p2.getName()); - assertEquals("call(* SimpleAspect.*(..))",p2.getPointcutExpression().asString()); - assertEquals(sa,p2.getDeclaringType()); - assertEquals(1,p2.getParameterTypes().length); - assertTrue(Modifier.isPrivate(p2.getModifiers())); - try { - Pointcut p3 = sa.getPointcut("sausages"); - fail("Expecting NoSuchPointcutExcetpion"); - } catch (NoSuchPointcutException ex) { - assertEquals("sausages",ex.getName()); - } - } - - public void testGetDeclaredPointcuts() { - Pointcut[] pcs = sa.getDeclaredPointcuts(); - assertEquals(2,pcs.length); - // AV was corrupted, cannot rely on ordering - String match = "simpleAspectMethodExecution--simpleAspectCall"; - assertTrue(match.indexOf(pcs[0].getName()) >= 0); - assertTrue(match.indexOf(pcs[1].getName()) >= 0); - } - - public void testGetPointcuts() { - Pointcut[] pcs = sa.getPointcuts(); - assertEquals(1,pcs.length); - assertEquals("simpleAspectMethodExecution",pcs[0].getName()); - } - - public void testGetDeclaredAdvice() { - Advice[] advice = sa.getDeclaredAdvice(); - assertEquals(10,advice.length); - advice = sa.getDeclaredAdvice(AdviceKind.BEFORE); - assertEquals(2,advice.length); - advice = sa.getDeclaredAdvice(AdviceKind.AFTER); - assertEquals(2,advice.length); - advice = sa.getDeclaredAdvice(AdviceKind.AFTER_RETURNING); - assertEquals(2,advice.length); - advice = sa.getDeclaredAdvice(AdviceKind.AFTER_THROWING); - assertEquals(2,advice.length); - advice = sa.getDeclaredAdvice(AdviceKind.AROUND); - assertEquals(2,advice.length); - advice = sa.getDeclaredAdvice(AdviceKind.BEFORE,AdviceKind.AFTER); - assertEquals(4,advice.length); - - advice = sa.getDeclaredAdvice(AdviceKind.BEFORE); - // AV: corrupted test: cannot rely on ordering since a Set is used behind - Advice aone, atwo; - if (advice[0].getName()!=null && advice[0].getName().length()>0) { - aone = advice[0]; - atwo = advice[1]; - } else { - aone = advice[1]; - atwo = advice[0]; - } - assertEquals("execution(* SimpleAspect.*(..))",aone.getPointcutExpression().toString()); - assertEquals("@AdviceName(\"logEntry\") before() : execution(* SimpleAspect.*(..))",aone.toString()); - assertEquals("logEntry",aone.getName()); - assertEquals(AdviceKind.BEFORE,aone.getKind()); - assertEquals("execution(* SimpleAspect.*(..))",atwo.getPointcutExpression().toString()); - assertEquals("",atwo.getName()); - assertEquals("before() : execution(* SimpleAspect.*(..))",atwo.toString()); - } - - public void testGetAdvice() { - Advice[] advice = sa.getDeclaredAdvice(); - assertEquals(10,advice.length); - advice = sa.getDeclaredAdvice(AdviceKind.BEFORE); - assertEquals(2,advice.length); - advice = sa.getDeclaredAdvice(AdviceKind.AFTER); - assertEquals(2,advice.length); - advice = sa.getDeclaredAdvice(AdviceKind.AFTER_RETURNING); - assertEquals(2,advice.length); - advice = sa.getDeclaredAdvice(AdviceKind.AFTER_THROWING); - assertEquals(2,advice.length); - advice = sa.getDeclaredAdvice(AdviceKind.AROUND); - assertEquals(2,advice.length); - advice = sa.getDeclaredAdvice(AdviceKind.BEFORE,AdviceKind.AFTER); - assertEquals(4,advice.length); - } - - public void testGetNamedAdvice() throws Exception { - Advice a = sa.getAdvice("logItAll"); - assertEquals("logItAll",a.getName()); - assertEquals(AdviceKind.AROUND,a.getKind()); - a = sa.getAdvice("whatGoesAround"); - assertEquals("whatGoesAround",a.getName()); - assertEquals(AdviceKind.AROUND,a.getKind()); - try { - a = sa.getAdvice("ajc$after$123"); - fail("Expecting NoSuchAdviceException"); - } catch (NoSuchAdviceException ex) { - assertEquals("ajc$after$123",ex.getName()); - } - try { - a = sa.getAdvice(""); - fail("Expecting IllegalArgumentException"); - } catch (IllegalArgumentException ex) { - ; - } - } - - public void testGetNamedDeclaredAdvice() throws Exception { - Advice a = sa.getDeclaredAdvice("logItAll"); - assertEquals("logItAll",a.getName()); - assertEquals(AdviceKind.AROUND,a.getKind()); - a = sa.getDeclaredAdvice("whatGoesAround"); - assertEquals("whatGoesAround",a.getName()); - assertEquals(AdviceKind.AROUND,a.getKind()); - try { - a = sa.getDeclaredAdvice("ajc$after$123"); - fail("Expecting NoSuchAdviceException"); - } catch (NoSuchAdviceException ex) { - assertEquals("ajc$after$123",ex.getName()); - } - try { - a = sa.getDeclaredAdvice(""); - fail("Expecting IllegalArgumentException"); - } catch (IllegalArgumentException ex) { - ; - } - } - - public void testIsPrivileged() { - assertFalse(sa.isPrivileged()); - assertTrue(AjTypeSystem.getAjType(SimplePrivilegedAspect.class).isPrivileged()); - } - - public void testIsAspect() { - assertTrue(sa.isAspect()); - } - - public void testIsMemberAspect() { - assertFalse(AjTypeSystem.getAjType(SimplePrivilegedAspect.class).isMemberAspect()); - assertTrue(AjTypeSystem.getAjType(SimplePrivilegedAspect.MemberAspect.class).isMemberAspect()); - - } - - public void testGetDeclareEoWarnings() { - DeclareErrorOrWarning[] deows = sa.getDeclareErrorOrWarnings(); - assertEquals(4,deows.length); - boolean foundCodeWarning = false; - boolean foundCodeError = false; - boolean foundAnnWarning = false; - boolean foundAnnError = false; - for (DeclareErrorOrWarning deow : deows) { - if (deow.isError()) { - if (deow.getMessage().equals("dont call this method code")) { - foundCodeError = true; - assertEquals("declare error : call(* DontDoIt.*(..)) : \"dont call this method code\"",deow.toString()); - } - if (deow.getMessage().equals("dont call this method ann")) foundAnnError = true; - assertEquals("call(* DontDoIt.*(..))",deow.getPointcutExpression().toString()); - } else { - if (deow.getMessage().equals("dont call this method code")) foundCodeWarning = true; - if (deow.getMessage().equals("dont call this method ann")) foundAnnWarning = true; - assertEquals("call(* DontDoIt.*(..))",deow.getPointcutExpression().toString()); - } - } - assertTrue(foundCodeWarning && foundAnnWarning && foundCodeError && foundAnnError); - } - -} - - -@Aspect -class SimpleAspect { - - // regular field - public String s; - - // synthetic field - public String ajc$xyz$s; - - // regular method - public void aMethod() {} - - // advice method, annotation style - @Before("execution(* SimpleAspect.*(..))") - public void logEntry() {} - - // advice method, code style - @Before("execution(* SimpleAspect.*(..))") - public void ajc$before$123() {} - - // advice method, annotation style - @After("execution(* SimpleAspect.*(..))") - public void logFinally() {} - - // advice method, code style - @After("execution(* SimpleAspect.*(..))") - public void ajc$after$123() {} - - // advice method, annotation style - @AfterReturning("execution(* SimpleAspect.*(..))") - public void logExit() {} - - // advice method, code style - @AfterReturning("execution(* SimpleAspect.*(..))") - public void ajc$afterReturning$123() {} - - // advice method, annotation style - @AfterThrowing("execution(* SimpleAspect.*(..))") - public void logException() {} - - // advice method, code style - @AfterThrowing("execution(* SimpleAspect.*(..))") - public void ajc$afterThrowing$123() {} - - // advice method, annotation style - @Around("execution(* SimpleAspect.*(..))") - public void logItAll() {} - - // advice method, code style - @Around("execution(* SimpleAspect.*(..))") - @AdviceName("whatGoesAround") - public void ajc$around$123() {} - - // pointcut, annotation style - @org.aspectj.lang.annotation.Pointcut("execution(* SimpleAspect.*(..))") - public void simpleAspectMethodExecution() {}; - - // pointcut, code style - @org.aspectj.lang.annotation.Pointcut("call(* SimpleAspect.*(..))") - private void ajc$pointcut$$simpleAspectCall$123(SimpleAspect target) {}; - - // decw, ann style - @DeclareWarning("call(* DontDoIt.*(..))") - public static final String dontDoIt = "dont call this method ann"; - - // decw, code style - @ajcDeclareEoW(pointcut="call(* DontDoIt.*(..))",message="dont call this method code",isError=false) - private void ajc$declare_eow$123() {} - - // dec., ann style - @DeclareError("call(* DontDoIt.*(..))") - public static final String dontDoItISaid = "dont call this method ann"; - - // decw, code style - @ajcDeclareEoW(pointcut="call(* DontDoIt.*(..))",message="dont call this method code",isError=true) - private void ajc$declare_eow$124() {} -} - -@Aspect -@ajcPrivileged -class SimplePrivilegedAspect { - - @Aspect - static class MemberAspect {} - -} - -@Aspect("perthis(pc())") -class PerThisAspect {} - -@Aspect("pertarget(pc())") -class PerTargetAspect {} - -@Aspect("percflow(pc())") -class PerCflowAspect {} - -@Aspect("percflowbelow(pc())") -class PerCflowbelowAspect {} - -@Aspect("pertypewithin(org.aspectj..*)") -class PerTypeWithin {} diff --git a/aspectj5rt/java5-testsrc/org/aspectj/internal/lang/reflect/InterTypeTests.java b/aspectj5rt/java5-testsrc/org/aspectj/internal/lang/reflect/InterTypeTests.java deleted file mode 100644 index ae7939bb6..000000000 --- a/aspectj5rt/java5-testsrc/org/aspectj/internal/lang/reflect/InterTypeTests.java +++ /dev/null @@ -1,88 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.internal.lang.reflect; - -import java.lang.reflect.Method; -import java.lang.reflect.Type; - -import org.aspectj.lang.reflect.AjType; -import org.aspectj.lang.reflect.AjTypeSystem; -import org.aspectj.lang.reflect.InterTypeConstructorDeclaration; -import org.aspectj.lang.reflect.InterTypeDeclaration; -import org.aspectj.lang.reflect.InterTypeFieldDeclaration; -import org.aspectj.lang.reflect.InterTypeMethodDeclaration; - -import junit.framework.TestCase; - -/** - * @author colyer - * - */ -public class InterTypeTests extends TestCase { - - public void testITDImpl() throws ClassNotFoundException { - AjType thisClass = AjTypeSystem.getAjType(InterTypeTests.class); - AjType runnable = AjTypeSystem.getAjType(java.lang.Runnable.class); - InterTypeDeclaration itd = new InterTypeDeclarationImpl(thisClass,"java.lang.Runnable",5); - assertEquals(thisClass,itd.getDeclaringType()); - assertEquals(runnable,itd.getTargetType()); - assertEquals(5, itd.getModifiers()); - } - - public void testITDField() throws ClassNotFoundException { - AjType thisClass = AjTypeSystem.getAjType(InterTypeTests.class); - AjType runnable = AjTypeSystem.getAjType(java.lang.Runnable.class); - InterTypeDeclaration itd = new InterTypeDeclarationImpl(thisClass,"java.lang.Runnable",5); - AjType stringType = AjTypeSystem.getAjType(java.lang.String.class); - Type t = Type.class; - InterTypeFieldDeclaration itdf = new InterTypeFieldDeclarationImpl(thisClass,"java.lang.Runnable",5,"f",stringType,t); - assertEquals("f",itdf.getName()); - assertEquals(stringType,itdf.getType()); - assertEquals(t,itdf.getGenericType()); - } - - public void testITDCons() throws ClassNotFoundException, NoSuchMethodException { - AjType thisClass = AjTypeSystem.getAjType(InterTypeTests.class); - AjType runnable = AjTypeSystem.getAjType(java.lang.Runnable.class); - Method base = InterTypeTests.class.getDeclaredMethod("interCons",InterTypeTests.class,String.class,int.class); - InterTypeConstructorDeclaration itdc = - new InterTypeConstructorDeclarationImpl(thisClass,"java.lang.Runnable",5,base); - assertEquals(2,itdc.getParameterTypes().length); - assertEquals(String.class,itdc.getParameterTypes()[0].getJavaClass()); - assertEquals(int.class,itdc.getParameterTypes()[1].getJavaClass()); - assertEquals(2,itdc.getGenericParameterTypes().length); - assertEquals(base.getGenericParameterTypes()[1],((AjType)itdc.getGenericParameterTypes()[0]).getJavaClass()); - assertEquals(base.getGenericParameterTypes()[2],((AjType)itdc.getGenericParameterTypes()[1]).getJavaClass()); - assertEquals(0,itdc.getExceptionTypes().length); - } - - public void testITDMethod() throws NoSuchMethodException { - AjType thisClass = AjTypeSystem.getAjType(InterTypeTests.class); - AjType runnable = AjTypeSystem.getAjType(java.lang.Runnable.class); - Method base = InterTypeTests.class.getDeclaredMethod("interMethod",InterTypeTests.class,String.class,int.class); - InterTypeMethodDeclaration itdm = new InterTypeMethodDeclarationImpl(thisClass,"java.lang.Runnable",5,"foo",base); - assertEquals("foo",itdm.getName()); - assertEquals(int.class,itdm.getReturnType().getJavaClass()); - assertEquals(int.class,((AjType)itdm.getGenericReturnType()).getJavaClass()); - assertEquals(2,itdm.getParameterTypes().length); - assertEquals(String.class,itdm.getParameterTypes()[0].getJavaClass()); - assertEquals(int.class,itdm.getParameterTypes()[1].getJavaClass()); - assertEquals(2,itdm.getGenericParameterTypes().length); - assertEquals(base.getGenericParameterTypes()[1],((AjType)itdm.getGenericParameterTypes()[0]).getJavaClass()); - assertEquals(base.getGenericParameterTypes()[2],((AjType)itdm.getGenericParameterTypes()[1]).getJavaClass()); - assertEquals(0,itdm.getExceptionTypes().length); - } - - public static void interCons(InterTypeTests itt, String s, int i) { } - - public static int interMethod(InterTypeTests itt, String s, int i) { return 5; } -} diff --git a/aspectj5rt/src/org/aspectj/lang/internal/lang/PlaceHolder.java b/aspectj5rt/src/org/aspectj/lang/internal/lang/PlaceHolder.java deleted file mode 100644 index 9edd4bcdf..000000000 --- a/aspectj5rt/src/org/aspectj/lang/internal/lang/PlaceHolder.java +++ /dev/null @@ -1,18 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Wes Isberg initial implementation - * ******************************************************************/ - - -package org.aspectj.lang.internal.lang; - -class PlaceHolder { - private static final long L = 1l; -} diff --git a/aspectj5rt/testsrc/org/aspectj/runtime/Aspectj5rtModuleTests.java b/aspectj5rt/testsrc/org/aspectj/runtime/Aspectj5rtModuleTests.java deleted file mode 100644 index 3eb333fe5..000000000 --- a/aspectj5rt/testsrc/org/aspectj/runtime/Aspectj5rtModuleTests.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.aspectj.runtime; -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Wes Isberg initial implementation - * ******************************************************************/ - -// default package -import org.aspectj.testing.util.TestUtil; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -public class Aspectj5rtModuleTests extends TestCase { - - public static Test suite() { - TestSuite suite = new TestSuite("Aspectj5rt module tests"); - if (TestUtil.is15VMOrGreater()) { - TestUtil.loadTestsReflectively(suite, "Aspectj5rt15ModuleTests", true); - } else { - suite.addTest(TestUtil.skipTest("for aspectj5rt that need 1.5")); - } - return suite; - } - -} diff --git a/aspectjtools/aspectjtools-assembly.xml b/aspectjtools/aspectjtools-assembly.xml new file mode 100644 index 000000000..310dbe098 --- /dev/null +++ b/aspectjtools/aspectjtools-assembly.xml @@ -0,0 +1,136 @@ + + + aspectjtools + + + jar + + + false + + + + + ../runtime/target/classes + . + + META-INF/maven/** + + + + + + ../weaver/target/classes + . + + META-INF/maven/** + + + + ../util/target/classes + . + + META-INF/maven/** + + + + ../bridge/target/classes + . + + META-INF/maven/** + + + + ../asm/target/classes + . + + META-INF/maven/** + + + + ../org.aspectj.matcher/target/classes + . + + META-INF/maven/** + + + + ../bcel-builder/target/classes + . + + META-INF/maven/** + + + + ../loadtime/target/classes + . + + META-INF/maven/** + + + + target/asm-unzipped + . + + META-INF/maven/** + org/** + META-INF/MANIFEST.MF + + + + + + ../ajbrowser/target/classes + . + + META-INF/maven/** + + + + ../ajde/target/classes + . + + META-INF/maven/** + + + + ../ajde.core/target/classes + . + + META-INF/maven/** + + + + ../ajdoc/target/classes + . + + META-INF/maven/** + + + + ../org.aspectj.ajdt.core/target/classes + . + + META-INF/maven/** + + + + ../taskdefs/target/classes + . + + META-INF/maven/** + + + + target/jdtcore-unzipped + . + + META-INF/MANIFEST.MF + + + + + + diff --git a/aspectjtools/aspectjtools-sources-assembly.xml b/aspectjtools/aspectjtools-sources-assembly.xml new file mode 100644 index 000000000..a382e5e8b --- /dev/null +++ b/aspectjtools/aspectjtools-sources-assembly.xml @@ -0,0 +1,85 @@ + + + sources + + + jar + + + false + + + + ../weaver/src/main/java + . + + + ../runtime/src/main/java + . + + + ../util/src/main/java + . + + + ../bridge/src/main/java + . + + + ../asm/src/main/java + . + + + ../org.aspectj.matcher/src/main/java + . + + + ../bcel-builder/src/main/java + . + + + ../loadtime/src/main/java + . + + + + + + ../ajbrowser/src/main/java + . + + + ../ajde/src/main/java + . + + + ../ajde.core/src/main/java + . + + + ../ajdoc/src/main/java + . + + + ../org.aspectj.ajdt.core/src/main/java + . + + + ../taskdefs/src/main/java + . + + + target/jdtcore-unzipped-src + . + + + + + diff --git a/aspectjtools/pom.xml b/aspectjtools/pom.xml new file mode 100644 index 000000000..88b5c2c1f --- /dev/null +++ b/aspectjtools/pom.xml @@ -0,0 +1,166 @@ + + + 4.0.0 + + + org.aspectj + aspectj-parent + 1.9.3.BUILD-SNAPSHOT + + + aspectjtools + pom + AspectJ Compiler + + + + org.aspectj + org.aspectj.ajdt.core + ${project.version} + + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + test-jar + + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + 1.6 + + + unzipasm + validate + + + + + + + + run + + + + + unzipjdt + validate + + + + + + + + run + + + + + unzipjdtsrc + validate + + + + + + + + run + + + + + + + maven-assembly-plugin + + + + + aspectjtools-assembly + package + + single + + + aspectjtools-${project.version} + false + + + org.aspectj.tools + + + + + org/aspectj/tools/ + + + AspectJ Tools Classes + ${project.version} + https://www.eclipse.org/aspectj/ + + org.aspectj.tools + ${project.version} + https://www.eclipse.org/aspectj/ + + AspectJ Tools + ${project.version} + (C) Copyright 1999-2001 Xerox Corporation, + 2002 Palo Alto Research Center, Incorporated (PARC), + 2003-2019 Contributors. All Rights Reserved + + + + + + + aspectjtools-assembly.xml + + + + + + aspectjtools-sources-assembly + package + + single + + + sources + aspectjtools-${project.version} + + + + aspectjtools-sources-assembly.xml + + + + + + + + + + diff --git a/docs/.project b/docs/.project deleted file mode 100644 index 111e0fa7a..000000000 --- a/docs/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - docs - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/loadtime5/.classpath b/loadtime5/.classpath deleted file mode 100644 index bf0c68bee..000000000 --- a/loadtime5/.classpath +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/loadtime5/.cvsignore b/loadtime5/.cvsignore deleted file mode 100644 index ba077a403..000000000 --- a/loadtime5/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -bin diff --git a/loadtime5/.project b/loadtime5/.project deleted file mode 100644 index a6d0b97da..000000000 --- a/loadtime5/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - loadtime5 - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/loadtime5/.settings/org.eclipse.jdt.core.prefs b/loadtime5/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 7341ab168..000000000 --- a/loadtime5/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,11 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.7 diff --git a/loadtime5/build.xml b/loadtime5/build.xml deleted file mode 100644 index a2a3e6243..000000000 --- a/loadtime5/build.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/loadtime5/java5-src/org/aspectj/weaver/loadtime/Agent.java b/loadtime5/java5-src/org/aspectj/weaver/loadtime/Agent.java deleted file mode 100644 index eeca8aeef..000000000 --- a/loadtime5/java5-src/org/aspectj/weaver/loadtime/Agent.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Alexandre Vasseur initial implementation - *******************************************************************************/ -package org.aspectj.weaver.loadtime; - -import java.lang.instrument.Instrumentation; -import java.lang.instrument.ClassFileTransformer; - -/** - * Java 1.5 preMain agent to hook in the class pre processor - * Can be used with -javaagent:aspectjweaver.jar - * - * @author Alexandre Vasseur - * @author Alexander Kriegisch - */ -public class Agent { - - /** - * The instrumentation instance - */ - private static Instrumentation s_instrumentation; - - /** - * The ClassFileTransformer wrapping the weaver - */ - private static ClassFileTransformer s_transformer = new ClassPreProcessorAgentAdapter(); - - /** - * JSR-163 preMain Agent entry method - * - * @param options - * @param instrumentation - */ - public static void premain(String options, Instrumentation instrumentation) { - /* Handle duplicate agents */ - if (s_instrumentation != null) { - return; - } - s_instrumentation = instrumentation; - s_instrumentation.addTransformer(s_transformer); - } - - public static void agentmain(String options, Instrumentation instrumentation) { - premain(options, instrumentation); - } - - /** - * Returns the Instrumentation system level instance - */ - public static Instrumentation getInstrumentation() { - if (s_instrumentation == null) { - throw new UnsupportedOperationException( - "AspectJ weaving agent was neither started via '-javaagent' (preMain) " + - "nor attached via 'VirtualMachine.loadAgent' (agentMain)"); - } - return s_instrumentation; - } - -} diff --git a/loadtime5/java5-src/org/aspectj/weaver/loadtime/ClassPreProcessorAgentAdapter.java b/loadtime5/java5-src/org/aspectj/weaver/loadtime/ClassPreProcessorAgentAdapter.java deleted file mode 100644 index a3201816a..000000000 --- a/loadtime5/java5-src/org/aspectj/weaver/loadtime/ClassPreProcessorAgentAdapter.java +++ /dev/null @@ -1,53 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005,2018 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - *******************************************************************************/ -package org.aspectj.weaver.loadtime; - -import java.lang.instrument.ClassFileTransformer; -import java.lang.instrument.IllegalClassFormatException; -import java.security.ProtectionDomain; - -/** - * Java 1.5 adapter for class pre processor - * - * @author Alexandre Vasseur - * @author Andy Clement - */ -public class ClassPreProcessorAgentAdapter implements ClassFileTransformer { - - private static ClassPreProcessor classPreProcessor; - - static { - try { - classPreProcessor = new Aj(); - classPreProcessor.initialize(); - } catch (Exception e) { - throw new ExceptionInInitializerError("could not initialize JSR163 preprocessor due to: " + e.toString()); - } - } - - /** - * Invokes the weaver to modify some set of input bytes. - * - * @param loader the defining class loader - * @param className the name of class being loaded - * @param classBeingRedefined is set when hotswap is being attempted - * @param protectionDomain the protection domain for the class being loaded - * @param bytes the incoming bytes (before weaving) - * @return the woven bytes - */ - @Override - public byte[] transform(ClassLoader loader, String className, Class classBeingRedefined, ProtectionDomain protectionDomain, - byte[] bytes) throws IllegalClassFormatException { - if (classBeingRedefined != null) { - System.err.println("INFO: (Enh120375): AspectJ attempting reweave of '" + className + "'"); - classPreProcessor.prepareForRedefinition(loader, className); - } - return classPreProcessor.preProcess(className, bytes, loader, protectionDomain); - } -} diff --git a/loadtime5/java5-testsrc/Loadtime515ModuleTests.java b/loadtime5/java5-testsrc/Loadtime515ModuleTests.java deleted file mode 100644 index 91d3aece8..000000000 --- a/loadtime5/java5-testsrc/Loadtime515ModuleTests.java +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: (See CVS logs) - * - *******************************************************************************/ - -import org.aspectj.weaver.loadtime.LoadtimeTests; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -/** - */ -public class Loadtime515ModuleTests extends TestCase { - - public static Test suite() { - TestSuite suite = new TestSuite(Loadtime515ModuleTests.class.getName()); - suite.addTestSuite(LoadtimeTests.class); - return suite; - } - -} diff --git a/loadtime5/java5-testsrc/org/aspectj/weaver/loadtime/LoadtimeTests.java b/loadtime5/java5-testsrc/org/aspectj/weaver/loadtime/LoadtimeTests.java deleted file mode 100644 index f777b7ff5..000000000 --- a/loadtime5/java5-testsrc/org/aspectj/weaver/loadtime/LoadtimeTests.java +++ /dev/null @@ -1,26 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Wes Isberg initial implementation - * ******************************************************************/ - - -package org.aspectj.weaver.loadtime; - -import java.lang.instrument.Instrumentation; - -import junit.framework.TestCase; - -public class LoadtimeTests extends TestCase { - - public void testPremain() throws Exception { - Class[] parmTypes = {String.class, Instrumentation.class }; - assertNotNull(Agent.class.getMethod("premain", parmTypes)); - } -} diff --git a/loadtime5/loadtime5.mf.txt b/loadtime5/loadtime5.mf.txt deleted file mode 100644 index cea0e5eda..000000000 --- a/loadtime5/loadtime5.mf.txt +++ /dev/null @@ -1,12 +0,0 @@ -Manifest-Version: 1.0 -Automatic-Module-Name: org.aspectj.weaver -Name: org/aspectj/weaver/ -Specification-Title: AspectJ Weaver Classes -Specification-Version: @build.version.short@ -Specification-Vendor: @company.name@ -Implementation-Title: org.aspectj.weaver -Implementation-Version: @build.version.short@ -Implementation-Vendor: @company.name@ -Premain-Class: org.aspectj.weaver.loadtime.Agent -Agent-Class: org.aspectj.weaver.loadtime.Agent -Can-Redefine-Classes: true diff --git a/loadtime5/testsrc/org/aspectj/loadtime/Loadtime5ModuleTests.java b/loadtime5/testsrc/org/aspectj/loadtime/Loadtime5ModuleTests.java deleted file mode 100644 index 665aecdc6..000000000 --- a/loadtime5/testsrc/org/aspectj/loadtime/Loadtime5ModuleTests.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.aspectj.loadtime; -/******************************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: (See CVS logs) - * - *******************************************************************************/ - -import org.aspectj.testing.util.TestUtil; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -/** - */ -public class Loadtime5ModuleTests extends TestCase { - - public static Test suite() { - TestSuite suite = new TestSuite(Loadtime5ModuleTests.class.getName()); - if (TestUtil.is15VMOrGreater()) { - TestUtil.loadTestsReflectively(suite, "Loadtime515ModuleTests", true); - } else { - suite.addTest(TestUtil.testNamed("all tests require 1.5")); - } - return suite; - } - public static void main(String[] args) { - junit.textui.TestRunner.main(new String[] {Loadtime5ModuleTests.class.getName()}); - } - -} diff --git a/weaver5/.classpath b/weaver5/.classpath deleted file mode 100644 index c54a89cea..000000000 --- a/weaver5/.classpath +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/weaver5/.cvsignore b/weaver5/.cvsignore deleted file mode 100644 index e1b17a04f..000000000 --- a/weaver5/.cvsignore +++ /dev/null @@ -1,6 +0,0 @@ -out -bin -default.lst -default.ajsym -.clover -bintest diff --git a/weaver5/.project b/weaver5/.project deleted file mode 100644 index 3f4e4f364..000000000 --- a/weaver5/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - weaver5 - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/weaver5/.settings/org.eclipse.jdt.core.prefs b/weaver5/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 1099c7bdc..000000000 --- a/weaver5/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,61 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.autoboxing=ignore -org.eclipse.jdt.core.compiler.problem.deprecation=ignore -org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled -org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled -org.eclipse.jdt.core.compiler.problem.discouragedReference=warning -org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore -org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore -org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning -org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning -org.eclipse.jdt.core.compiler.problem.forbiddenReference=error -org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning -org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning -org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore -org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore -org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore -org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning -org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore -org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore -org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore -org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning -org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning -org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore -org.eclipse.jdt.core.compiler.problem.nullReference=ignore -org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning -org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore -org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore -org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore -org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled -org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning -org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled -org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore -org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning -org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=ignore -org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore -org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning -org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore -org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore -org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore -org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled -org.eclipse.jdt.core.compiler.problem.unusedImport=warning -org.eclipse.jdt.core.compiler.problem.unusedLabel=warning -org.eclipse.jdt.core.compiler.problem.unusedLocal=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled -org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled -org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=ignore -org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=ignore -org.eclipse.jdt.core.compiler.source=1.7 diff --git a/weaver5/.settings/org.eclipse.jdt.ui.prefs b/weaver5/.settings/org.eclipse.jdt.ui.prefs deleted file mode 100644 index 60c05a46a..000000000 --- a/weaver5/.settings/org.eclipse.jdt.ui.prefs +++ /dev/null @@ -1,3 +0,0 @@ -#Mon Sep 26 14:56:47 BST 2005 -eclipse.preferences.version=1 -internal.default.compliance=default diff --git a/weaver5/build.xml b/weaver5/build.xml deleted file mode 100644 index 5fc6b3443..000000000 --- a/weaver5/build.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/weaver5/java5-src/org/aspectj/weaver/reflect/ArgNameFinder.java b/weaver5/java5-src/org/aspectj/weaver/reflect/ArgNameFinder.java deleted file mode 100644 index 25945a90a..000000000 --- a/weaver5/java5-src/org/aspectj/weaver/reflect/ArgNameFinder.java +++ /dev/null @@ -1,26 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005-2017 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * ******************************************************************/ -package org.aspectj.weaver.reflect; - -import java.lang.reflect.Member; - -/** - * @author Adrian Colyer - * @author Andy Clement - */ -public interface ArgNameFinder { - - /** - * Attempt to discover the parameter names for a reflectively obtained member. - * @param forMember the member for which parameter names are being looked up - * @return parameter names or null if names can't be determined - */ - String[] getParameterNames(Member forMember); - -} diff --git a/weaver5/java5-src/org/aspectj/weaver/reflect/DeferredResolvedPointcutDefinition.java b/weaver5/java5-src/org/aspectj/weaver/reflect/DeferredResolvedPointcutDefinition.java deleted file mode 100644 index b0af93f16..000000000 --- a/weaver5/java5-src/org/aspectj/weaver/reflect/DeferredResolvedPointcutDefinition.java +++ /dev/null @@ -1,35 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2006 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ - -package org.aspectj.weaver.reflect; - -import org.aspectj.weaver.ResolvedPointcutDefinition; -import org.aspectj.weaver.UnresolvedType; - -/** - * When a Java15ReflectionBasedDelegate gets the pointcuts for a given class it tries to resolve them before returning. This can - * cause problems if the resolution of one pointcut in the type depends on another pointcut in the same type. Therefore the - * algorithm proceeds in two phases, first we create and store instances of this class in the pointcuts array, and once that is - * done, we come back round and resolve the actual pointcut expression. This means that if we recurse doing resolution, we will find - * the named pointcut we are looking for! - * - * @author adrian colyer - * - */ -public class DeferredResolvedPointcutDefinition extends ResolvedPointcutDefinition { - - public DeferredResolvedPointcutDefinition(UnresolvedType declaringType, int modifiers, String name, - UnresolvedType[] parameterTypes) { - super(declaringType, modifiers, name, parameterTypes, UnresolvedType.VOID, null); - } - -} diff --git a/weaver5/java5-src/org/aspectj/weaver/reflect/InternalUseOnlyPointcutParser.java b/weaver5/java5-src/org/aspectj/weaver/reflect/InternalUseOnlyPointcutParser.java deleted file mode 100644 index 8d81d7b08..000000000 --- a/weaver5/java5-src/org/aspectj/weaver/reflect/InternalUseOnlyPointcutParser.java +++ /dev/null @@ -1,43 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2006 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ - -package org.aspectj.weaver.reflect; - -import org.aspectj.weaver.patterns.Pointcut; -import org.aspectj.weaver.tools.PointcutParameter; -import org.aspectj.weaver.tools.PointcutParser; - -public class InternalUseOnlyPointcutParser extends PointcutParser { - - public InternalUseOnlyPointcutParser(ClassLoader classLoader, ReflectionWorld world) { - super(); - setClassLoader(classLoader); - setWorld(world); - } - - public InternalUseOnlyPointcutParser(ClassLoader classLoader) { - super(); - setClassLoader(classLoader); - } - - public Pointcut resolvePointcutExpression( - String expression, - Class inScope, - PointcutParameter[] formalParameters) { - return super.resolvePointcutExpression(expression, inScope, formalParameters); - } - - public Pointcut concretizePointcutExpression(Pointcut pc, Class inScope, PointcutParameter[] formalParameters) { - return super.concretizePointcutExpression(pc, inScope, formalParameters); - } - -} diff --git a/weaver5/java5-src/org/aspectj/weaver/reflect/Java15AnnotationFinder.java b/weaver5/java5-src/org/aspectj/weaver/reflect/Java15AnnotationFinder.java deleted file mode 100644 index 016becf87..000000000 --- a/weaver5/java5-src/org/aspectj/weaver/reflect/Java15AnnotationFinder.java +++ /dev/null @@ -1,386 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005, 2017 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * ******************************************************************/ -package org.aspectj.weaver.reflect; - -import java.lang.annotation.Annotation; -import java.lang.reflect.AccessibleObject; -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.Member; -import java.lang.reflect.Method; - -import org.aspectj.apache.bcel.classfile.AnnotationDefault; -import org.aspectj.apache.bcel.classfile.Attribute; -import org.aspectj.apache.bcel.classfile.JavaClass; -import org.aspectj.apache.bcel.classfile.LocalVariable; -import org.aspectj.apache.bcel.classfile.LocalVariableTable; -import org.aspectj.apache.bcel.util.ClassLoaderRepository; -import org.aspectj.apache.bcel.util.NonCachingClassLoaderRepository; -import org.aspectj.apache.bcel.util.Repository; -import org.aspectj.weaver.AnnotationAJ; -import org.aspectj.weaver.ResolvedType; -import org.aspectj.weaver.UnresolvedType; -import org.aspectj.weaver.World; -import org.aspectj.weaver.bcel.BcelAnnotation; -import org.aspectj.weaver.bcel.BcelWeakClassLoaderReference; - -/** - * - * @author Adrian Colyer - * @author Andy Clement - */ -public class Java15AnnotationFinder implements AnnotationFinder, ArgNameFinder { - - public static final ResolvedType[][] NO_PARAMETER_ANNOTATIONS = new ResolvedType[][] {}; - - private Repository bcelRepository; - private BcelWeakClassLoaderReference classLoaderRef; - private World world; - private static boolean useCachingClassLoaderRepository; - - static { - try { - useCachingClassLoaderRepository = System.getProperty("Xset:bcelRepositoryCaching","true").equalsIgnoreCase("true"); - } catch (Throwable t) { - useCachingClassLoaderRepository = false; - } - } - - // must have no-arg constructor for reflective construction - public Java15AnnotationFinder() { - } - - public void setClassLoader(ClassLoader aLoader) { - this.classLoaderRef = new BcelWeakClassLoaderReference(aLoader); - if (useCachingClassLoaderRepository) { - this.bcelRepository = new ClassLoaderRepository(classLoaderRef); - } else { - this.bcelRepository = new NonCachingClassLoaderRepository(classLoaderRef); - } - } - - public void setWorld(World aWorld) { - this.world = aWorld; - } - - public Object getAnnotation(ResolvedType annotationType, Object onObject) { - try { - Class annotationClass = (Class) Class.forName(annotationType.getName(), - false, getClassLoader()); - if (onObject.getClass().isAnnotationPresent(annotationClass)) { - return onObject.getClass().getAnnotation(annotationClass); - } - } catch (ClassNotFoundException ex) { - // just return null - } - return null; - } - - public Object getAnnotationFromClass(ResolvedType annotationType, Class aClass) { - try { - Class annotationClass = (Class) Class.forName(annotationType.getName(), - false, getClassLoader()); - if (aClass.isAnnotationPresent(annotationClass)) { - return aClass.getAnnotation(annotationClass); - } - } catch (ClassNotFoundException ex) { - // just return null - } - return null; - } - - public Object getAnnotationFromMember(ResolvedType annotationType, Member aMember) { - if (!(aMember instanceof AccessibleObject)) - return null; - AccessibleObject ao = (AccessibleObject) aMember; - try { - Class annotationClass = Class.forName(annotationType.getName(), false, getClassLoader()); - if (ao.isAnnotationPresent(annotationClass)) { - return ao.getAnnotation(annotationClass); - } - } catch (ClassNotFoundException ex) { - // just return null - } - return null; - } - - private ClassLoader getClassLoader() { - return classLoaderRef.getClassLoader(); - } - - public AnnotationAJ getAnnotationOfType(UnresolvedType ofType, Member onMember) { - if (!(onMember instanceof AccessibleObject)) - return null; - // here we really want both the runtime visible AND the class visible - // annotations - // so we bail out to Bcel and then chuck away the JavaClass so that we - // don't hog - // memory. - try { - JavaClass jc = bcelRepository.loadClass(onMember.getDeclaringClass()); - org.aspectj.apache.bcel.classfile.annotation.AnnotationGen[] anns = new org.aspectj.apache.bcel.classfile.annotation.AnnotationGen[0]; - if (onMember instanceof Method) { - org.aspectj.apache.bcel.classfile.Method bcelMethod = jc.getMethod((Method) onMember); - if (bcelMethod == null) { - // pr220430 - // System.err.println( - // "Unexpected problem in Java15AnnotationFinder: cannot retrieve annotations on method '" - // + - // onMember.getName()+"' in class '"+jc.getClassName()+"'"); - } else { - anns = bcelMethod.getAnnotations(); - } - } else if (onMember instanceof Constructor) { - org.aspectj.apache.bcel.classfile.Method bcelCons = jc.getMethod((Constructor) onMember); - anns = bcelCons.getAnnotations(); - } else if (onMember instanceof Field) { - org.aspectj.apache.bcel.classfile.Field bcelField = jc.getField((Field) onMember); - anns = bcelField.getAnnotations(); - } - // the answer is cached and we don't want to hold on to memory - bcelRepository.clear(); - // OPTIMIZE make constant 0 size array for sharing - if (anns == null) - anns = new org.aspectj.apache.bcel.classfile.annotation.AnnotationGen[0]; - // convert to our Annotation type - for (int i = 0; i < anns.length; i++) { - if (anns[i].getTypeSignature().equals(ofType.getSignature())) { - return new BcelAnnotation(anns[i], world); - } - } - return null; - } catch (ClassNotFoundException cnfEx) { - // just use reflection then - } - return null; - } - - public String getAnnotationDefaultValue(Member onMember) { - try { - JavaClass jc = bcelRepository.loadClass(onMember.getDeclaringClass()); - if (onMember instanceof Method) { - org.aspectj.apache.bcel.classfile.Method bcelMethod = jc.getMethod((Method) onMember); - - if (bcelMethod == null) { - // pr220430 - // System.err.println( - // "Unexpected problem in Java15AnnotationFinder: cannot retrieve annotations on method '" - // + - // onMember.getName()+"' in class '"+jc.getClassName()+"'"); - } else { - Attribute[] attrs = bcelMethod.getAttributes(); - for (int i = 0; i < attrs.length; i++) { - Attribute attribute = attrs[i]; - if (attribute.getName().equals("AnnotationDefault")) { - AnnotationDefault def = (AnnotationDefault) attribute; - return def.getElementValue().stringifyValue(); - } - } - return null; - } - } - } catch (ClassNotFoundException cnfEx) { - // just use reflection then - } - return null; - } - - public ResolvedType[] getAnnotations(Member onMember, boolean areRuntimeAnnotationsSufficient) { - if (!(onMember instanceof AccessibleObject)) { - return ResolvedType.NONE; - } - // If annotations with class level retention are required then we need to open - // open the class file. If only runtime retention annotations are required - // we can just use reflection. - if (!areRuntimeAnnotationsSufficient) { - try { - JavaClass jc = bcelRepository.loadClass(onMember.getDeclaringClass()); - org.aspectj.apache.bcel.classfile.annotation.AnnotationGen[] anns = null; - if (onMember instanceof Method) { - org.aspectj.apache.bcel.classfile.Method bcelMethod = jc.getMethod((Method) onMember); - if (bcelMethod != null) { - anns = bcelMethod.getAnnotations(); - } - } else if (onMember instanceof Constructor) { - org.aspectj.apache.bcel.classfile.Method bcelCons = jc.getMethod((Constructor) onMember); - anns = bcelCons.getAnnotations(); - } else if (onMember instanceof Field) { - org.aspectj.apache.bcel.classfile.Field bcelField = jc.getField((Field) onMember); - anns = bcelField.getAnnotations(); - } - // the answer is cached and we don't want to hold on to memory - bcelRepository.clear(); - if (anns == null || anns.length == 0) { - return ResolvedType.NONE; - } - ResolvedType[] annotationTypes = new ResolvedType[anns.length]; - for (int i = 0; i < anns.length; i++) { - annotationTypes[i] = world.resolve(UnresolvedType.forSignature(anns[i].getTypeSignature())); - } - return annotationTypes; - } catch (ClassNotFoundException cnfEx) { - // just use reflection then - } - } - - AccessibleObject ao = (AccessibleObject) onMember; - Annotation[] anns = ao.getDeclaredAnnotations(); - if (anns.length == 0) { - return ResolvedType.NONE; - } - ResolvedType[] annotationTypes = new ResolvedType[anns.length]; - for (int i = 0; i < anns.length; i++) { - annotationTypes[i] = UnresolvedType.forName(anns[i].annotationType().getName()).resolve(world); - } - return annotationTypes; - } - - public ResolvedType[] getAnnotations(Class forClass, World inWorld) { - // here we really want both the runtime visible AND the class visible - // annotations so we bail out to Bcel and then chuck away the JavaClass so that we - // don't hog memory. - try { - JavaClass jc = bcelRepository.loadClass(forClass); - org.aspectj.apache.bcel.classfile.annotation.AnnotationGen[] anns = jc.getAnnotations(); - bcelRepository.clear(); - if (anns == null) { - return ResolvedType.NONE; - } else { - ResolvedType[] ret = new ResolvedType[anns.length]; - for (int i = 0; i < ret.length; i++) { - ret[i] = inWorld.resolve(UnresolvedType.forSignature(anns[i].getTypeSignature())); - } - return ret; - } - } catch (ClassNotFoundException cnfEx) { - // just use reflection then - } - - Annotation[] classAnnotations = forClass.getAnnotations(); - ResolvedType[] ret = new ResolvedType[classAnnotations.length]; - for (int i = 0; i < classAnnotations.length; i++) { - ret[i] = inWorld.resolve(classAnnotations[i].annotationType().getName()); - } - - return ret; - } - - public String[] getParameterNames(Member forMember) { - if (!(forMember instanceof AccessibleObject)) - return null; - - try { - JavaClass jc = bcelRepository.loadClass(forMember.getDeclaringClass()); - LocalVariableTable lvt = null; - int numVars = 0; - if (forMember instanceof Method) { - org.aspectj.apache.bcel.classfile.Method bcelMethod = jc.getMethod((Method) forMember); - lvt = bcelMethod.getLocalVariableTable(); - numVars = bcelMethod.getArgumentTypes().length; - } else if (forMember instanceof Constructor) { - org.aspectj.apache.bcel.classfile.Method bcelCons = jc.getMethod((Constructor) forMember); - lvt = bcelCons.getLocalVariableTable(); - numVars = bcelCons.getArgumentTypes().length; - } - return getParameterNamesFromLVT(lvt, numVars); - } catch (ClassNotFoundException cnfEx) { - ; // no luck - } - - return null; - } - - private String[] getParameterNamesFromLVT(LocalVariableTable lvt, int numVars) { - if (lvt == null) - return null;// pr222987 - prevent NPE - LocalVariable[] vars = lvt.getLocalVariableTable(); - if (vars.length < numVars) { - // basic error, we can't get the names... - return null; - } - String[] ret = new String[numVars]; - for (int i = 0; i < numVars; i++) { - ret[i] = vars[i + 1].getName(); - } - return ret; - } - - public ResolvedType[][] getParameterAnnotationTypes(Member onMember) { - if (!(onMember instanceof AccessibleObject)) - return NO_PARAMETER_ANNOTATIONS; - // here we really want both the runtime visible AND the class visible - // annotations - // so we bail out to Bcel and then chuck away the JavaClass so that we - // don't hog - // memory. - try { - JavaClass jc = bcelRepository.loadClass(onMember.getDeclaringClass()); - org.aspectj.apache.bcel.classfile.annotation.AnnotationGen[][] anns = null; - if (onMember instanceof Method) { - org.aspectj.apache.bcel.classfile.Method bcelMethod = jc.getMethod((Method) onMember); - if (bcelMethod == null) { - // pr220430 - // System.err.println( - // "Unexpected problem in Java15AnnotationFinder: cannot retrieve annotations on method '" - // + - // onMember.getName()+"' in class '"+jc.getClassName()+"'"); - } else { - anns = bcelMethod.getParameterAnnotations(); - } - } else if (onMember instanceof Constructor) { - org.aspectj.apache.bcel.classfile.Method bcelCons = jc.getMethod((Constructor) onMember); - anns = bcelCons.getParameterAnnotations(); - } else if (onMember instanceof Field) { - // anns = null; - } - // the answer is cached and we don't want to hold on to memory - bcelRepository.clear(); - if (anns == null) - return NO_PARAMETER_ANNOTATIONS; - ResolvedType[][] result = new ResolvedType[anns.length][]; - // CACHING?? - for (int i = 0; i < anns.length; i++) { - if (anns[i] != null) { - result[i] = new ResolvedType[anns[i].length]; - for (int j = 0; j < anns[i].length; j++) { - result[i][j] = world.resolve(UnresolvedType.forSignature(anns[i][j].getTypeSignature())); - } - } - } - return result; - } catch (ClassNotFoundException cnfEx) { - // just use reflection then - } - - // reflection... - AccessibleObject ao = (AccessibleObject) onMember; - Annotation[][] anns = null; - if (onMember instanceof Method) { - anns = ((Method) ao).getParameterAnnotations(); - } else if (onMember instanceof Constructor) { - anns = ((Constructor) ao).getParameterAnnotations(); - } else if (onMember instanceof Field) { - // anns = null; - } - if (anns == null) - return NO_PARAMETER_ANNOTATIONS; - ResolvedType[][] result = new ResolvedType[anns.length][]; - // CACHING?? - for (int i = 0; i < anns.length; i++) { - if (anns[i] != null) { - result[i] = new ResolvedType[anns[i].length]; - for (int j = 0; j < anns[i].length; j++) { - result[i][j] = UnresolvedType.forName(anns[i][j].annotationType().getName()).resolve(world); - } - } - } - return result; - } - -} diff --git a/weaver5/java5-src/org/aspectj/weaver/reflect/Java15GenericSignatureInformationProvider.java b/weaver5/java5-src/org/aspectj/weaver/reflect/Java15GenericSignatureInformationProvider.java deleted file mode 100644 index c9de9517e..000000000 --- a/weaver5/java5-src/org/aspectj/weaver/reflect/Java15GenericSignatureInformationProvider.java +++ /dev/null @@ -1,103 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.weaver.reflect; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.Member; -import java.lang.reflect.Method; -import java.lang.reflect.Type; - -import org.aspectj.weaver.UnresolvedType; -import org.aspectj.weaver.World; - -/** - * Uses Java 1.5 reflection APIs to determine generic signatures - */ -public class Java15GenericSignatureInformationProvider implements - GenericSignatureInformationProvider { - - private final World world; - - public Java15GenericSignatureInformationProvider(World forWorld) { - this.world = forWorld; - } - - /* (non-Javadoc) - * @see org.aspectj.weaver.reflect.GenericSignatureInformationProvider#getGenericParameterTypes(org.aspectj.weaver.reflect.ReflectionBasedResolvedMemberImpl) - */ - public UnresolvedType[] getGenericParameterTypes( - ReflectionBasedResolvedMemberImpl resolvedMember) { - JavaLangTypeToResolvedTypeConverter typeConverter = new JavaLangTypeToResolvedTypeConverter(world); - Type[] pTypes = new Type[0]; - Member member = resolvedMember.getMember(); - if (member instanceof Method) { - pTypes = ((Method)member).getGenericParameterTypes(); - } else if (member instanceof Constructor) { - pTypes = ((Constructor)member).getGenericParameterTypes(); - } - return typeConverter.fromTypes(pTypes); - } - - /* (non-Javadoc) - * @see org.aspectj.weaver.reflect.GenericSignatureInformationProvider#getGenericReturnType(org.aspectj.weaver.reflect.ReflectionBasedResolvedMemberImpl) - */ - public UnresolvedType getGenericReturnType( - ReflectionBasedResolvedMemberImpl resolvedMember) { - JavaLangTypeToResolvedTypeConverter typeConverter = new JavaLangTypeToResolvedTypeConverter(world); - Member member = resolvedMember.getMember(); - if (member instanceof Field) { - return typeConverter.fromType(((Field)member).getGenericType()); - } else if (member instanceof Method) { - return typeConverter.fromType(((Method)member).getGenericReturnType()); - } else if (member instanceof Constructor) { - return typeConverter.fromType(((Constructor)member).getDeclaringClass()); - } else { - throw new IllegalStateException("unexpected member type: " + member); - } - } - - /* (non-Javadoc) - * @see org.aspectj.weaver.reflect.GenericSignatureInformationProvider#isBridge() - */ - public boolean isBridge(ReflectionBasedResolvedMemberImpl resolvedMember) { - Member member = resolvedMember.getMember(); - if (member instanceof Method) { - return ((Method)member).isBridge(); - } else { - return false; - } - } - - /* (non-Javadoc) - * @see org.aspectj.weaver.reflect.GenericSignatureInformationProvider#isVarArgs() - */ - public boolean isVarArgs(ReflectionBasedResolvedMemberImpl resolvedMember) { - Member member = resolvedMember.getMember(); - if (member instanceof Method) { - return ((Method)member).isVarArgs(); - } else if (member instanceof Constructor) { - return ((Constructor)member).isVarArgs(); - } else { - return false; - } - } - - /* (non-Javadoc) - * @see org.aspectj.weaver.reflect.GenericSignatureInformationProvider#isSynthetic() - */ - public boolean isSynthetic(ReflectionBasedResolvedMemberImpl resolvedMember) { - Member member = resolvedMember.getMember(); - return member.isSynthetic(); - } - -} diff --git a/weaver5/java5-src/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java b/weaver5/java5-src/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java deleted file mode 100644 index 6b65ed31e..000000000 --- a/weaver5/java5-src/org/aspectj/weaver/reflect/Java15ReflectionBasedReferenceTypeDelegate.java +++ /dev/null @@ -1,389 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.weaver.reflect; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.reflect.Constructor; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.lang.reflect.Type; -import java.util.Iterator; -import java.util.Set; - -import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.reflect.AjType; -import org.aspectj.lang.reflect.AjTypeSystem; -import org.aspectj.lang.reflect.Pointcut; -import org.aspectj.weaver.AnnotationAJ; -import org.aspectj.weaver.ReferenceType; -import org.aspectj.weaver.ResolvedMember; -import org.aspectj.weaver.ResolvedPointcutDefinition; -import org.aspectj.weaver.ResolvedType; -import org.aspectj.weaver.TypeVariable; -import org.aspectj.weaver.TypeVariableReferenceType; -import org.aspectj.weaver.UnresolvedType; -import org.aspectj.weaver.World; -import org.aspectj.weaver.tools.PointcutDesignatorHandler; -import org.aspectj.weaver.tools.PointcutParameter; - -/** - * Provides Java 5 behaviour in reflection based delegates (overriding 1.4 behaviour from superclass where - * appropriate) - * - * @author Adrian Colyer - * @author Andy Clement - */ -public class Java15ReflectionBasedReferenceTypeDelegate extends ReflectionBasedReferenceTypeDelegate { - - private AjType myType; - private ResolvedType[] annotations; - private ResolvedMember[] pointcuts; - private ResolvedMember[] methods; - private ResolvedMember[] fields; - private TypeVariable[] typeVariables; - private ResolvedType superclass; - private ResolvedType[] superInterfaces; - private String genericSignature = null; - private JavaLangTypeToResolvedTypeConverter typeConverter; - private Java15AnnotationFinder annotationFinder = null; - private ArgNameFinder argNameFinder = null; - - public Java15ReflectionBasedReferenceTypeDelegate() { - } - - @Override - public void initialize(ReferenceType aType, Class aClass, ClassLoader classLoader, World aWorld) { - super.initialize(aType, aClass, classLoader, aWorld); - myType = AjTypeSystem.getAjType(aClass); - annotationFinder = new Java15AnnotationFinder(); - argNameFinder = annotationFinder; - annotationFinder.setClassLoader(this.classLoaderReference.getClassLoader()); - annotationFinder.setWorld(aWorld); - this.typeConverter = new JavaLangTypeToResolvedTypeConverter(aWorld); - } - - @Override - public ReferenceType buildGenericType() { - return (ReferenceType) UnresolvedType.forGenericTypeVariables(getResolvedTypeX().getSignature(), getTypeVariables()) - .resolve(getWorld()); - } - - @Override - public AnnotationAJ[] getAnnotations() { - // AMC - we seem not to need to implement this method... - // throw new UnsupportedOperationException( - // "getAnnotations on Java15ReflectionBasedReferenceTypeDelegate is not implemented yet" - // ); - // FIXME is this the right implementation in the reflective case? - return super.getAnnotations(); - } - - @Override - public ResolvedType[] getAnnotationTypes() { - if (annotations == null) { - annotations = annotationFinder.getAnnotations(getBaseClass(), getWorld()); - } - return annotations; - } - - @Override - public boolean hasAnnotations() { - if (annotations == null) { - annotations = annotationFinder.getAnnotations(getBaseClass(), getWorld()); - } - return annotations.length != 0; - } - - @Override - public boolean hasAnnotation(UnresolvedType ofType) { - ResolvedType[] myAnns = getAnnotationTypes(); - ResolvedType toLookFor = ofType.resolve(getWorld()); - for (int i = 0; i < myAnns.length; i++) { - if (myAnns[i] == toLookFor) { - return true; - } - } - return false; - } - - // use the MAP to ensure that any aj-synthetic fields are filtered out - @Override - public ResolvedMember[] getDeclaredFields() { - if (fields == null) { - Field[] reflectFields = this.myType.getDeclaredFields(); - ResolvedMember[] rFields = new ResolvedMember[reflectFields.length]; - for (int i = 0; i < reflectFields.length; i++) { - rFields[i] = createGenericFieldMember(reflectFields[i]); - } - this.fields = rFields; - } - return fields; - } - - @Override - public String getDeclaredGenericSignature() { - if (this.genericSignature == null && isGeneric()) { - // BUG? what the hell is this doing - see testcode in MemberTestCase15.testMemberSignatureCreation() and run it - // off a Reflection World - } - return genericSignature; - } - - @Override - public ResolvedType[] getDeclaredInterfaces() { - if (superInterfaces == null) { - Type[] genericInterfaces = getBaseClass().getGenericInterfaces(); - this.superInterfaces = typeConverter.fromTypes(genericInterfaces); - } - return superInterfaces; - } - - @Override - public ResolvedType getSuperclass() { - // Superclass of object is null - if (superclass == null && getBaseClass() != Object.class) { - Type t = this.getBaseClass().getGenericSuperclass(); - if (t != null) { - superclass = typeConverter.fromType(t); - } - if (t == null) { - // If the superclass is null, return Object - same as bcel does - superclass = getWorld().resolve(UnresolvedType.OBJECT); - } - } - return superclass; - } - - @Override - public TypeVariable[] getTypeVariables() { - TypeVariable[] workInProgressSetOfVariables = getResolvedTypeX().getWorld().getTypeVariablesCurrentlyBeingProcessed( - getBaseClass()); - if (workInProgressSetOfVariables != null) { - return workInProgressSetOfVariables; - } - if (this.typeVariables == null) { - java.lang.reflect.TypeVariable[] tVars = this.getBaseClass().getTypeParameters(); - TypeVariable[] rTypeVariables = new TypeVariable[tVars.length]; - // basic initialization - for (int i = 0; i < tVars.length; i++) { - rTypeVariables[i] = new TypeVariable(tVars[i].getName()); - } - // stash it - this.getResolvedTypeX().getWorld().recordTypeVariablesCurrentlyBeingProcessed(getBaseClass(), rTypeVariables); - // now fill in the details... - for (int i = 0; i < tVars.length; i++) { - TypeVariableReferenceType tvrt = ((TypeVariableReferenceType) typeConverter.fromType(tVars[i])); - TypeVariable tv = tvrt.getTypeVariable(); - rTypeVariables[i].setSuperclass(tv.getSuperclass()); - rTypeVariables[i].setAdditionalInterfaceBounds(tv.getSuperInterfaces()); - rTypeVariables[i].setDeclaringElement(tv.getDeclaringElement()); - rTypeVariables[i].setDeclaringElementKind(tv.getDeclaringElementKind()); - rTypeVariables[i].setRank(tv.getRank()); - } - this.typeVariables = rTypeVariables; - this.getResolvedTypeX().getWorld().forgetTypeVariablesCurrentlyBeingProcessed(getBaseClass()); - } - return this.typeVariables; - } - - // overrides super method since by using the MAP we can filter out advice - // methods that really shouldn't be seen in this list - @Override - public ResolvedMember[] getDeclaredMethods() { - if (methods == null) { - Method[] reflectMethods = this.myType.getDeclaredMethods(); - Constructor[] reflectCons = this.myType.getDeclaredConstructors(); - ResolvedMember[] rMethods = new ResolvedMember[reflectMethods.length + reflectCons.length]; - for (int i = 0; i < reflectMethods.length; i++) { - rMethods[i] = createGenericMethodMember(reflectMethods[i]); - } - for (int i = 0; i < reflectCons.length; i++) { - rMethods[i + reflectMethods.length] = createGenericConstructorMember(reflectCons[i]); - } - this.methods = rMethods; - } - return methods; - } - - /** - * Returns the generic type, regardless of the resolvedType we 'know about' - */ - public ResolvedType getGenericResolvedType() { - ResolvedType rt = getResolvedTypeX(); - if (rt.isParameterizedType() || rt.isRawType()) { - return rt.getGenericType(); - } - return rt; - } - - private ResolvedMember createGenericMethodMember(Method forMethod) { - ReflectionBasedResolvedMemberImpl ret = new ReflectionBasedResolvedMemberImpl(org.aspectj.weaver.Member.METHOD, - getGenericResolvedType(), forMethod.getModifiers(), typeConverter.fromType(forMethod.getReturnType()), - forMethod.getName(), typeConverter.fromTypes(forMethod.getParameterTypes()), typeConverter.fromTypes(forMethod - .getExceptionTypes()), forMethod); - ret.setAnnotationFinder(this.annotationFinder); - ret.setGenericSignatureInformationProvider(new Java15GenericSignatureInformationProvider(this.getWorld())); - return ret; - } - - private ResolvedMember createGenericConstructorMember(Constructor forConstructor) { - ReflectionBasedResolvedMemberImpl ret = new ReflectionBasedResolvedMemberImpl(org.aspectj.weaver.Member.METHOD, - getGenericResolvedType(), forConstructor.getModifiers(), - // to return what BCEL returns the return type is void - UnresolvedType.VOID,// getGenericResolvedType(), - "", typeConverter.fromTypes(forConstructor.getParameterTypes()), typeConverter.fromTypes(forConstructor - .getExceptionTypes()), forConstructor); - ret.setAnnotationFinder(this.annotationFinder); - ret.setGenericSignatureInformationProvider(new Java15GenericSignatureInformationProvider(this.getWorld())); - return ret; - } - - private ResolvedMember createGenericFieldMember(Field forField) { - ReflectionBasedResolvedMemberImpl ret = new ReflectionBasedResolvedMemberImpl(org.aspectj.weaver.Member.FIELD, - getGenericResolvedType(), forField.getModifiers(), typeConverter.fromType(forField.getType()), forField.getName(), - new UnresolvedType[0], forField); - ret.setAnnotationFinder(this.annotationFinder); - ret.setGenericSignatureInformationProvider(new Java15GenericSignatureInformationProvider(this.getWorld())); - return ret; - } - - @Override - public ResolvedMember[] getDeclaredPointcuts() { - if (pointcuts == null) { - Pointcut[] pcs = this.myType.getDeclaredPointcuts(); - pointcuts = new ResolvedMember[pcs.length]; - InternalUseOnlyPointcutParser parser = null; - World world = getWorld(); - if (world instanceof ReflectionWorld) { - parser = new InternalUseOnlyPointcutParser(classLoaderReference.getClassLoader(), (ReflectionWorld) getWorld()); - } else { - parser = new InternalUseOnlyPointcutParser(classLoaderReference.getClassLoader()); - } - Set additionalPointcutHandlers = world.getRegisteredPointcutHandlers(); - for (Iterator handlerIterator = additionalPointcutHandlers.iterator(); handlerIterator.hasNext();) { - PointcutDesignatorHandler handler = (PointcutDesignatorHandler) handlerIterator.next(); - parser.registerPointcutDesignatorHandler(handler); - } - - // phase 1, create legitimate entries in pointcuts[] before we - // attempt to resolve *any* of the pointcuts - // resolution can sometimes cause us to recurse, and this two stage - // process allows us to cope with that - for (int i = 0; i < pcs.length; i++) { - AjType[] ptypes = pcs[i].getParameterTypes(); - UnresolvedType[] weaverPTypes = new UnresolvedType[ptypes.length]; - for (int j = 0; j < weaverPTypes.length; j++) { - weaverPTypes[j] = this.typeConverter.fromType(ptypes[j].getJavaClass()); - } - pointcuts[i] = new DeferredResolvedPointcutDefinition(getResolvedTypeX(), pcs[i].getModifiers(), pcs[i].getName(), - weaverPTypes); - } - // phase 2, now go back round and resolve in-place all of the - // pointcuts - PointcutParameter[][] parameters = new PointcutParameter[pcs.length][]; - for (int i = 0; i < pcs.length; i++) { - AjType[] ptypes = pcs[i].getParameterTypes(); - String[] pnames = pcs[i].getParameterNames(); - if (pnames.length != ptypes.length) { - pnames = tryToDiscoverParameterNames(pcs[i]); - if (pnames == null || (pnames.length != ptypes.length)) { - throw new IllegalStateException("Required parameter names not available when parsing pointcut " - + pcs[i].getName() + " in type " + getResolvedTypeX().getName()); - } - } - parameters[i] = new PointcutParameter[ptypes.length]; - for (int j = 0; j < parameters[i].length; j++) { - parameters[i][j] = parser.createPointcutParameter(pnames[j], ptypes[j].getJavaClass()); - } - String pcExpr = pcs[i].getPointcutExpression().toString(); - org.aspectj.weaver.patterns.Pointcut pc = parser.resolvePointcutExpression(pcExpr, getBaseClass(), parameters[i]); - ((ResolvedPointcutDefinition) pointcuts[i]).setParameterNames(pnames); - ((ResolvedPointcutDefinition) pointcuts[i]).setPointcut(pc); - } - // phase 3, now concretize them all - for (int i = 0; i < pointcuts.length; i++) { - ResolvedPointcutDefinition rpd = (ResolvedPointcutDefinition) pointcuts[i]; - rpd.setPointcut(parser.concretizePointcutExpression(rpd.getPointcut(), getBaseClass(), parameters[i])); - } - } - return pointcuts; - } - - // for @AspectJ pointcuts compiled by javac only... - private String[] tryToDiscoverParameterNames(Pointcut pcut) { - Method[] ms = pcut.getDeclaringType().getJavaClass().getDeclaredMethods(); - for (Method m : ms) { - if (m.getName().equals(pcut.getName())) { - return argNameFinder.getParameterNames(m); - } - } - return null; - } - - @Override - public boolean isAnnotation() { - return getBaseClass().isAnnotation(); - } - - @Override - public boolean isAnnotationStyleAspect() { - return getBaseClass().isAnnotationPresent(Aspect.class); - } - - @Override - public boolean isAnnotationWithRuntimeRetention() { - if (!isAnnotation()) { - return false; - } - if (getBaseClass().isAnnotationPresent(Retention.class)) { - Retention retention = (Retention) getBaseClass().getAnnotation(Retention.class); - RetentionPolicy policy = retention.value(); - return policy == RetentionPolicy.RUNTIME; - } else { - return false; - } - } - - @Override - public boolean isAspect() { - return this.myType.isAspect(); - } - - @Override - public boolean isEnum() { - return getBaseClass().isEnum(); - } - - @Override - public boolean isGeneric() { - // return false; // for now - return getBaseClass().getTypeParameters().length > 0; - } - - @Override - public boolean isAnonymous() { - return this.myClass.isAnonymousClass(); - } - - @Override - public boolean isNested() { - return this.myClass.isMemberClass(); - } - - @Override - public ResolvedType getOuterClass() { - return ReflectionBasedReferenceTypeDelegateFactory.resolveTypeInWorld( - myClass.getEnclosingClass(),world); - } - -} diff --git a/weaver5/java5-src/org/aspectj/weaver/reflect/JavaLangTypeToResolvedTypeConverter.java b/weaver5/java5-src/org/aspectj/weaver/reflect/JavaLangTypeToResolvedTypeConverter.java deleted file mode 100644 index 30983e38f..000000000 --- a/weaver5/java5-src/org/aspectj/weaver/reflect/JavaLangTypeToResolvedTypeConverter.java +++ /dev/null @@ -1,134 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * ******************************************************************/ -package org.aspectj.weaver.reflect; - -import java.lang.reflect.GenericArrayType; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.lang.reflect.WildcardType; -import java.util.HashMap; -import java.util.Map; - -import org.aspectj.weaver.BoundedReferenceType; -import org.aspectj.weaver.ReferenceType; -import org.aspectj.weaver.ResolvedType; -import org.aspectj.weaver.TypeFactory; -import org.aspectj.weaver.TypeVariable; -import org.aspectj.weaver.TypeVariableReferenceType; -import org.aspectj.weaver.UnresolvedType; -import org.aspectj.weaver.World; - -/** - * Handles the translation of java.lang.reflect.Type objects into AspectJ UnresolvedTypes. - * - * @author Adrian Colyer - */ -public class JavaLangTypeToResolvedTypeConverter { - - // Used to prevent recursion - we record what we are working on and return it if asked again *whilst* working on it - private Map typeVariablesInProgress = new HashMap(); - private final World world; - - public JavaLangTypeToResolvedTypeConverter(World aWorld) { - this.world = aWorld; - } - - private World getWorld() { - return this.world; - } - - public ResolvedType fromType(Type type) { - if (type instanceof Class) { - Class clazz = (Class) type; - String name = clazz.getName(); - /** - * getName() can return: - * - * 1. If this class object represents a reference type that is not an - * array type then the binary name of the class is returned - * 2. If this class object represents a primitive type or void, then - * the name returned is a String equal to the Java language keyword - * corresponding to the primitive type or void. - * 3. If this class object represents a class of arrays, then the internal - * form of the name consists of the name of the element type preceded by - * one or more '[' characters representing the depth of the array nesting. - */ - if (clazz.isArray()) { - UnresolvedType ut = UnresolvedType.forSignature(name.replace('.', '/')); - return getWorld().resolve(ut); - } else { - return getWorld().resolve(name); - } - } else if (type instanceof ParameterizedType) { - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=509327 - // TODO should deal with the ownerType if it set, indicating this is possibly an inner type of a parameterized type - Type ownerType = ((ParameterizedType) type).getOwnerType(); - ParameterizedType parameterizedType = (ParameterizedType) type; - ResolvedType baseType = fromType(parameterizedType.getRawType()); - Type[] typeArguments = parameterizedType.getActualTypeArguments(); - if (baseType.isSimpleType() && typeArguments.length == 0 && ownerType != null) { - // 'type' is an inner type of some outer parameterized type - // For now just return the base type - in future create the parameterized form of the outer - // and use it with the inner. We return the base type to be compatible with what the - // code does that accesses the info from the bytecode (unlike this code which accesses it - // reflectively). - return baseType; - } - ResolvedType[] resolvedTypeArguments = fromTypes(typeArguments); - return TypeFactory.createParameterizedType(baseType, resolvedTypeArguments, getWorld()); - } else if (type instanceof java.lang.reflect.TypeVariable) { - TypeVariableReferenceType inprogressVar = typeVariablesInProgress.get(type); - if (inprogressVar != null) { - return inprogressVar; - } - java.lang.reflect.TypeVariable tv = (java.lang.reflect.TypeVariable) type; - TypeVariable rt_tv = new TypeVariable(tv.getName()); - TypeVariableReferenceType tvrt = new TypeVariableReferenceType(rt_tv, getWorld()); - typeVariablesInProgress.put(type, tvrt); // record what we are working on, for recursion case - Type[] bounds = tv.getBounds(); - ResolvedType[] resBounds = fromTypes(bounds); - ResolvedType upperBound = resBounds[0]; - ResolvedType[] additionalBounds = new ResolvedType[0]; - if (resBounds.length > 1) { - additionalBounds = new ResolvedType[resBounds.length - 1]; - System.arraycopy(resBounds, 1, additionalBounds, 0, additionalBounds.length); - } - rt_tv.setUpperBound(upperBound); - rt_tv.setAdditionalInterfaceBounds(additionalBounds); - typeVariablesInProgress.remove(type); // we have finished working on it - return tvrt; - } else if (type instanceof WildcardType) { - WildcardType wildType = (WildcardType) type; - Type[] lowerBounds = wildType.getLowerBounds(); - Type[] upperBounds = wildType.getUpperBounds(); - ResolvedType bound = null; - boolean isExtends = lowerBounds.length == 0; - if (isExtends) { - bound = fromType(upperBounds[0]); - } else { - bound = fromType(lowerBounds[0]); - } - return new BoundedReferenceType((ReferenceType) bound, isExtends, getWorld()); - } else if (type instanceof GenericArrayType) { - GenericArrayType genericArrayType = (GenericArrayType) type; - Type componentType = genericArrayType.getGenericComponentType(); - return UnresolvedType.makeArray(fromType(componentType), 1).resolve(getWorld()); - } - return ResolvedType.MISSING; - } - - public ResolvedType[] fromTypes(Type[] types) { - ResolvedType[] ret = new ResolvedType[types.length]; - for (int i = 0; i < ret.length; i++) { - ret[i] = fromType(types[i]); - } - return ret; - } - -} diff --git a/weaver5/java5-src/org/aspectj/weaver/tools/Jdk14Trace.java b/weaver5/java5-src/org/aspectj/weaver/tools/Jdk14Trace.java deleted file mode 100644 index 061b0b0a0..000000000 --- a/weaver5/java5-src/org/aspectj/weaver/tools/Jdk14Trace.java +++ /dev/null @@ -1,127 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Matthew Webster - initial implementation - *******************************************************************************/ -package org.aspectj.weaver.tools; - -import java.util.logging.Handler; -import java.util.logging.Level; -import java.util.logging.Logger; - -// OPTIMIZE move out for now? check what doc says about using these variants on trace (commons/14) -public class Jdk14Trace extends AbstractTrace { - - private Logger logger; - private String name; - - public Jdk14Trace (Class clazz) { - super(clazz); - this.name = clazz.getName(); - this.logger = Logger.getLogger(name); - } - - public void enter(String methodName, Object thiz, Object[] args) { - if (logger.isLoggable(Level.FINE)) { - logger.entering(name,methodName,formatObj(thiz)); - if (args != null && logger.isLoggable(Level.FINER)) { - logger.entering(name,methodName,formatObjects(args)); - } - } - } - - public void enter(String methodName, Object thiz) { - enter(methodName,thiz,null); - } - - public void exit(String methodName, Object ret) { - if (logger.isLoggable(Level.FINE)) { - logger.exiting(name,methodName,formatObj(ret)); - } - } - - public void exit(String methodName, Throwable th) { - if (logger.isLoggable(Level.FINE)) { - logger.exiting(name,methodName,th); - } - } - - public void exit(String methodName) { - if (logger.isLoggable(Level.FINE)) { - logger.exiting(name,methodName); - } - } - - public void event(String methodName, Object thiz, Object[] args) { - if (logger.isLoggable(Level.FINE)) { - logger.logp(Level.FINER,name,methodName,"EVENT",formatObj(thiz)); - if (args != null && logger.isLoggable(Level.FINER)) { - logger.logp(Level.FINER,name,methodName,"EVENT",formatObjects(args)); - } - } - } - - public void event(String methodName) { - if (logger.isLoggable(Level.FINE)) { - logger.logp(Level.FINER,name,methodName,"EVENT"); - } - } - - public boolean isTraceEnabled() { - return logger.isLoggable(Level.FINER); - } - - public void setTraceEnabled (boolean b) { - if (b) { - logger.setLevel(Level.FINER); - Handler[] handlers = logger.getHandlers(); - if (handlers.length == 0) { - Logger parent = logger.getParent(); - if (parent != null) handlers = parent.getHandlers(); - } - for (int i = 0; i < handlers.length; i++) { - Handler handler = handlers[i]; - handler.setLevel(Level.FINER); - } - } - else { - logger.setLevel(Level.INFO); - } - } - - public void debug (String message) { - if (logger.isLoggable(Level.FINE)) { - logger.fine(message); - } - } - - public void info(String message) { - if (logger.isLoggable(Level.INFO)) { - logger.info(message); - } - } - - public void warn (String message, Throwable th) { - if (logger.isLoggable(Level.WARNING)) { - logger.log(Level.WARNING,message,th); - } - } - - public void error (String message, Throwable th) { - if (logger.isLoggable(Level.SEVERE)) { - logger.log(Level.SEVERE,message,th); - } - } - - public void fatal (String message, Throwable th) { - if (logger.isLoggable(Level.SEVERE)) { - logger.log(Level.SEVERE,message,th); - } - } - -} diff --git a/weaver5/java5-src/org/aspectj/weaver/tools/Jdk14TraceFactory.java b/weaver5/java5-src/org/aspectj/weaver/tools/Jdk14TraceFactory.java deleted file mode 100644 index 4043d1d33..000000000 --- a/weaver5/java5-src/org/aspectj/weaver/tools/Jdk14TraceFactory.java +++ /dev/null @@ -1,20 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Matthew Webster - initial implementation - *******************************************************************************/ -package org.aspectj.weaver.tools; - -public class Jdk14TraceFactory extends TraceFactory { - - @Override - public Trace getTrace(Class clazz) { - return new Jdk14Trace(clazz); - } - -} diff --git a/weaver5/java5-testsrc/$Proxy1.java b/weaver5/java5-testsrc/$Proxy1.java deleted file mode 100644 index 51cae8b05..000000000 --- a/weaver5/java5-testsrc/$Proxy1.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Andy Clement - initial API and implementation - *******************************************************************************/ -import java.io.Serializable; -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Proxy; - -public class $Proxy1 extends Proxy implements MessageService { - - protected $Proxy1(InvocationHandler arg0) { - super(arg0); - } - - public Object get1(Long t) { - return null; - } - - public Object get2(Serializable s) { - return null; - } -} diff --git a/weaver5/java5-testsrc/CounterAspect.java b/weaver5/java5-testsrc/CounterAspect.java deleted file mode 100644 index 1ca126d02..000000000 --- a/weaver5/java5-testsrc/CounterAspect.java +++ /dev/null @@ -1,52 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2008 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Andy Clement initial implementation - * ******************************************************************/ -import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.annotation.Before; -import org.aspectj.lang.annotation.Pointcut; - -/** - * Created to enable PointcutDesignatorHandlerTests.testParsingBeanInReferencePointcut01 and 02 to run - * - * @author Andy Clement - */ -@Aspect -public class CounterAspect { - - int count; - - @Before("execution(* set*(..)) && bean(testBean1)") - public void increment1ForAnonymousPointcut() { - count++; - } - - @Pointcut("execution(* toString(..)) && bean(testBean1)") - public void testBean1toString() { - } - - @Pointcut("execution(* setAge(..)) && bean(testBean1)") - public void testBean1SetAge() { - } - - @Pointcut("execution(* setAge(..)) && bean(testBean2)") - public void testBean2SetAge() { - } - - @Before("testBean1SetAge()") - public void increment1() { - count++; - } - - @Before("testBean2SetAge()") - public void increment2() { - count++; - } -} \ No newline at end of file diff --git a/weaver5/java5-testsrc/GenericService.java b/weaver5/java5-testsrc/GenericService.java deleted file mode 100644 index 87f5c0419..000000000 --- a/weaver5/java5-testsrc/GenericService.java +++ /dev/null @@ -1,17 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Andy Clement - initial API and implementation - *******************************************************************************/ -import java.io.Serializable; - -public interface GenericService { - Object get1(T t); - - Object get2(Serializable s); -} diff --git a/weaver5/java5-testsrc/MA.java b/weaver5/java5-testsrc/MA.java deleted file mode 100644 index 270882586..000000000 --- a/weaver5/java5-testsrc/MA.java +++ /dev/null @@ -1,15 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2008 Contributors - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors - * Andy Clement - * ******************************************************************/ - -public @interface MA { - -} diff --git a/weaver5/java5-testsrc/MB.java b/weaver5/java5-testsrc/MB.java deleted file mode 100644 index 3ff3eede4..000000000 --- a/weaver5/java5-testsrc/MB.java +++ /dev/null @@ -1,15 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2008 Contributors - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors - * Andy Clement - * ******************************************************************/ - -public @interface MB { - -} diff --git a/weaver5/java5-testsrc/MC.java b/weaver5/java5-testsrc/MC.java deleted file mode 100644 index d48133baf..000000000 --- a/weaver5/java5-testsrc/MC.java +++ /dev/null @@ -1,15 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2008 Contributors - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors - * Andy Clement - * ******************************************************************/ - -public @interface MC { - -} diff --git a/weaver5/java5-testsrc/MD.java b/weaver5/java5-testsrc/MD.java deleted file mode 100644 index 47a61cba0..000000000 --- a/weaver5/java5-testsrc/MD.java +++ /dev/null @@ -1,15 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2008 Contributors - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors - * Andy Clement - * ******************************************************************/ - -public @interface MD { - -} diff --git a/weaver5/java5-testsrc/MessageService.java b/weaver5/java5-testsrc/MessageService.java deleted file mode 100644 index 160aecc21..000000000 --- a/weaver5/java5-testsrc/MessageService.java +++ /dev/null @@ -1,13 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009 Contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Andy Clement - initial API and implementation - *******************************************************************************/ -public interface MessageService extends GenericService { - -} diff --git a/weaver5/java5-testsrc/org/aspectj/matcher/tools/ReflectionWorldAdvancedPointcutExpressionTests.java b/weaver5/java5-testsrc/org/aspectj/matcher/tools/ReflectionWorldAdvancedPointcutExpressionTests.java deleted file mode 100644 index d93daffd3..000000000 --- a/weaver5/java5-testsrc/org/aspectj/matcher/tools/ReflectionWorldAdvancedPointcutExpressionTests.java +++ /dev/null @@ -1,30 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2008 Contributors - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Andy Clement - * ******************************************************************/ -package org.aspectj.matcher.tools; - -import org.aspectj.weaver.World; -import org.aspectj.weaver.reflect.ReflectionWorld; - -/** - * Run all the pointcut parsing/matching tests against a ReflectionWorld. - * - * @author Andy Clement - */ -public class ReflectionWorldAdvancedPointcutExpressionTests extends CommonAdvancedPointcutExpressionTests { - - protected World getWorld() { - World w = new ReflectionWorld(false, getClass().getClassLoader()); - w.setBehaveInJava5Way(true); - return w; - } - -} diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/AllTracing5Tests.java b/weaver5/java5-testsrc/org/aspectj/weaver/AllTracing5Tests.java deleted file mode 100644 index bf68cb56c..000000000 --- a/weaver5/java5-testsrc/org/aspectj/weaver/AllTracing5Tests.java +++ /dev/null @@ -1,27 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Matthew Webster - initial implementation - *******************************************************************************/ -package org.aspectj.weaver; - -import junit.framework.Test; -import junit.framework.TestSuite; - -public class AllTracing5Tests { - - public static Test suite() { - TestSuite suite = new TestSuite(AllTracing5Tests.class.getName()); - //$JUnit-BEGIN$ - suite.addTestSuite(Jdk14TraceFactoryTest.class); - suite.addTestSuite(Jdk14TraceTest.class); - //$JUnit-END$ - return suite; - } - -} diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/AllWeaver5Tests.java b/weaver5/java5-testsrc/org/aspectj/weaver/AllWeaver5Tests.java deleted file mode 100644 index 54f35656f..000000000 --- a/weaver5/java5-testsrc/org/aspectj/weaver/AllWeaver5Tests.java +++ /dev/null @@ -1,40 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005-2006 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * Matthew Webster Move from default package - * ******************************************************************/ -package org.aspectj.weaver; - -import junit.framework.Test; -import junit.framework.TestSuite; - -import org.aspectj.weaver.reflect.ReflectionWorldReferenceTypeTest; -import org.aspectj.weaver.reflect.ReflectionWorldSpecificTest; -import org.aspectj.weaver.tools.PointcutExpressionTest; - -public class AllWeaver5Tests { - - public static Test suite() { - TestSuite suite = new TestSuite(AllWeaver5Tests.class.getName()); - // $JUnit-BEGIN$ - suite.addTest(AllTracing5Tests.suite()); - suite.addTest(BcweaverModuleTests15.suite()); - suite.addTestSuite(ReflectionWorldReferenceTypeTest.class); - suite.addTestSuite(PointcutExpressionTest.class); - suite.addTestSuite(JoinPointSignatureIteratorTests.class); - // gives incompatible class version error... - // suite.addTestSuite(ReflectionWorldAdvancedPointcutExpressionTests.class - // ); - suite.addTestSuite(ReflectionWorldSpecificTest.class); - // $JUnit-END$ - return suite; - } - -} diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/BcweaverModuleTests15.java b/weaver5/java5-testsrc/org/aspectj/weaver/BcweaverModuleTests15.java deleted file mode 100644 index 4ae4d7beb..000000000 --- a/weaver5/java5-testsrc/org/aspectj/weaver/BcweaverModuleTests15.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.aspectj.weaver; - -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -import org.aspectj.weaver.bcel.BcelGenericSignatureToTypeXTestCase; -import org.aspectj.weaver.bcel.BcelWorldReferenceTypeTest; -import org.aspectj.weaver.patterns.WildTypePatternResolutionTestCase; -import org.aspectj.weaver.tools.Java15PointcutExpressionTest; - -public class BcweaverModuleTests15 extends TestCase { - public static Test suite() { - TestSuite suite = new TestSuite(BcweaverModuleTests15.class.getName()); - suite.addTestSuite(BcelGenericSignatureToTypeXTestCase.class); - suite.addTestSuite(BoundedReferenceTypeTestCase.class); - suite.addTest(Java15PointcutExpressionTest.suite()); - suite.addTestSuite(MemberTestCase15.class); - suite.addTestSuite(BcelWorldReferenceTypeTest.class); - suite.addTest(TestJava5ReflectionBasedReferenceTypeDelegate.suite()); - suite.addTestSuite(TypeVariableTestCase.class); - suite.addTestSuite(TypeVariableReferenceTypeTestCase.class); - suite.addTestSuite(WildTypePatternResolutionTestCase.class); - return suite; - } - - public BcweaverModuleTests15(String name) { - super(name); - } -} diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/BoundedReferenceTypeTestCase.java b/weaver5/java5-testsrc/org/aspectj/weaver/BoundedReferenceTypeTestCase.java deleted file mode 100644 index 403b2ecb1..000000000 --- a/weaver5/java5-testsrc/org/aspectj/weaver/BoundedReferenceTypeTestCase.java +++ /dev/null @@ -1,106 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.weaver; - -import junit.framework.TestCase; - -import org.aspectj.weaver.bcel.BcelWorld; - -public class BoundedReferenceTypeTestCase extends TestCase { - - ReferenceType javaLangClass; - ReferenceType javaLangObject; - BoundedReferenceType extendsClass; - BoundedReferenceType superClass; - BoundedReferenceType extendsWithExtras; - - public void testSignature() { - String extendsSig = extendsClass.getSignature(); - assertEquals("+Ljava/lang/Class;", extendsSig); - assertEquals("-Ljava/lang/Class;", superClass.getSignature()); - } - - public void testExtendsBounds() { - assertFalse("has no lower bound", extendsClass.hasLowerBound()); - assertNull("no lower bound", extendsClass.getLowerBound()); - assertEquals(javaLangClass, extendsClass.getUpperBound()); - assertEquals("no interface bounds", 0, extendsClass.getAdditionalBounds().length); - } - - public void testSuperBounds() { - assertTrue("has lower bound", superClass.hasLowerBound()); - assertEquals(javaLangClass, superClass.getLowerBound()); - assertEquals("Ljava/lang/Object;", superClass.getUpperBound().getSignature()); - assertEquals("no interface bounds", 0, superClass.getAdditionalBounds().length); - } - - public void testIsExtends() { - assertTrue(extendsClass.kind == BoundedReferenceType.EXTENDS); - assertFalse(superClass.kind == BoundedReferenceType.EXTENDS); - } - - public void testIsSuper() { - assertTrue(superClass.kind == BoundedReferenceType.SUPER); - assertFalse(extendsClass.kind == BoundedReferenceType.SUPER); - } - - public void testGetDeclaredInterfacesNoAdditions() { - ResolvedType[] rt1 = extendsClass.getDeclaredInterfaces(); - ResolvedType[] rt2 = javaLangClass.getDeclaredInterfaces(); - assertEquals("same length", rt1.length, rt2.length); - for (int i = 0; i < rt2.length; i++) { - assertEquals("same methods", rt1[i], rt2[i]); - } - } - - public void testGetDeclaredInterfacesWithInterfaceBounds() { - ResolvedType[] rt1 = extendsWithExtras.getDeclaredInterfaces(); - ResolvedType[] rt2 = javaLangClass.getDeclaredInterfaces(); - assertEquals("one extra interface", rt1.length, rt2.length + 1); - for (int i = 0; i < rt2.length; i++) { - assertEquals("same methods", rt1[i], rt2[i]); - } - assertEquals("Ljava/util/List;", rt1[rt1.length - 1].getSignature()); - } - - // all other methods in signature are delegated to upper bound... - // representative test - public void testGetDeclaredMethodsExtends() { - ResolvedMember[] rm1 = extendsClass.getDeclaredMethods(); - ResolvedMember[] rm2 = javaLangClass.getDeclaredMethods(); - assertEquals("same length", rm1.length, rm2.length); - for (int i = 0; i < rm2.length; i++) { - assertEquals("same methods", rm1[i], rm2[i]); - } - } - - public void testGetDeclaredMethodsSuper() { - ResolvedMember[] rm1 = superClass.getDeclaredMethods(); - ResolvedMember[] rm2 = javaLangObject.getDeclaredMethods(); - assertEquals("same length", rm1.length, rm2.length); - for (int i = 0; i < rm2.length; i++) { - assertEquals("same methods", rm1[i], rm2[i]); - } - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - BcelWorld world = new BcelWorld(); - javaLangClass = (ReferenceType) world.resolve(UnresolvedType.forName("java/lang/Class")); - javaLangObject = (ReferenceType) world.resolve(UnresolvedType.OBJECT); - extendsClass = new BoundedReferenceType(javaLangClass, true, world); - superClass = new BoundedReferenceType(javaLangClass, false, world); - extendsWithExtras = new BoundedReferenceType(javaLangClass, true, world, new ReferenceType[] { (ReferenceType) world - .resolve(UnresolvedType.forName("java/util/List")) }); - } -} diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/CommonReferenceTypeTests.java b/weaver5/java5-testsrc/org/aspectj/weaver/CommonReferenceTypeTests.java deleted file mode 100644 index 8d683e8af..000000000 --- a/weaver5/java5-testsrc/org/aspectj/weaver/CommonReferenceTypeTests.java +++ /dev/null @@ -1,91 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.weaver; - -import junit.framework.TestCase; - -// test cases for Adrian's additions to ReferenceType -// XXX - couldn't find any unit test cases for the rest of the ReferenceType class -public abstract class CommonReferenceTypeTests extends TestCase { - - private World world; - - public abstract World getWorld(); - - public void setUp() { - world = getWorld(); - } - - public void testUnresolvedTypeSignatureProcessing() { - world.setBehaveInJava5Way(true); - UnresolvedType ut = null; - ut = UnresolvedType.forName("java.util.List>[]").resolve(world); - ut = UnresolvedType.forSignature("[Pjava/util/List;>;").resolve(world); - assertEquals("Signatures not equal ", "[Pjava/util/List;>;", ut.getSignature()); - assertEquals("Names not equal ", "java.util.List>[]", ut.getName()); - } - - public void testArrays() { - world.setBehaveInJava5Way(true); - UnresolvedType ut = null; - ut = UnresolvedType.forName("[Ljava.lang.String;"); - assertEquals("[Ljava/lang/String;",ut.getSignature()); - UnresolvedType reified = UnresolvedType.forSignature(ut.getSignature()); - ResolvedType rt = world.resolve(reified); - assertEquals("[Ljava/lang/String;",rt.getSignature()); - assertEquals("java.lang.String[]",rt.getName()); - assertFalse(rt.isMissing()); - - ut = UnresolvedType.forName("[[[[Ljava.lang.String;"); - assertEquals("[[[[Ljava/lang/String;",ut.getSignature()); - reified = UnresolvedType.forSignature(ut.getSignature()); - rt = world.resolve(reified); - assertEquals("[[[[Ljava/lang/String;",rt.getSignature()); - assertEquals("java.lang.String[][][][]",rt.getName()); - assertTrue(rt.isArray()); - assertTrue(rt.getComponentType().isArray()); - assertFalse(rt.isMissing()); - } - - public void testIsRawTrue() { - world.setBehaveInJava5Way(true); - UnresolvedType javaLangClass = UnresolvedType.forName("java.lang.Class"); - ResolvedType rtx = world.resolve(javaLangClass); - assertTrue("Resolves to reference type", (rtx instanceof ReferenceType)); - ReferenceType rt = (ReferenceType) rtx; - assertTrue("java.lang.Class is raw", rt.isRawType()); - } - - public void testIsRawFalse() { - world.setBehaveInJava5Way(true); - UnresolvedType javaLangObject = UnresolvedType.forName("java.lang.Object"); - ResolvedType rtx = world.resolve(javaLangObject); - assertTrue("Resolves to reference type", (rtx instanceof ReferenceType)); - ReferenceType rt = (ReferenceType) rtx; - assertFalse("java.lang.Object is not raw", rt.isRawType()); - } - - public void testIsGenericTrue() { - world.setBehaveInJava5Way(true); - UnresolvedType javaLangClass = UnresolvedType.forName("java.lang.Class"); - ResolvedType rtx = world.resolve(javaLangClass); - assertTrue("java.lang.Class has underpinning generic type", rtx.getGenericType().isGenericType()); - } - - public void testIsGenericFalse() { - world.setBehaveInJava5Way(true); - UnresolvedType javaLangObject = UnresolvedType.forName("java.lang.Object"); - ResolvedType rtx = world.resolve(javaLangObject); - assertFalse(rtx.isGenericType()); - } - -} diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/Jdk14TraceFactoryTest.java b/weaver5/java5-testsrc/org/aspectj/weaver/Jdk14TraceFactoryTest.java deleted file mode 100644 index cec4d6a3d..000000000 --- a/weaver5/java5-testsrc/org/aspectj/weaver/Jdk14TraceFactoryTest.java +++ /dev/null @@ -1,30 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Matthew Webster - initial implementation - *******************************************************************************/ -package org.aspectj.weaver; - -import junit.framework.TestCase; - -import org.aspectj.weaver.tools.Jdk14TraceFactory; -import org.aspectj.weaver.tools.Trace; - -public class Jdk14TraceFactoryTest extends TestCase { - - public void testJdk14TraceFactory() { - new Jdk14TraceFactory(); - } - - public void testGetTrace() { - Jdk14TraceFactory factory = new Jdk14TraceFactory(); - Trace trace = factory.getTrace(getClass()); - assertFalse("Tracing should be disbled by default",trace.isTraceEnabled()); - } - -} diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/Jdk14TraceTest.java b/weaver5/java5-testsrc/org/aspectj/weaver/Jdk14TraceTest.java deleted file mode 100644 index 0c694cc9d..000000000 --- a/weaver5/java5-testsrc/org/aspectj/weaver/Jdk14TraceTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Matthew Webster - initial implementation - *******************************************************************************/ -package org.aspectj.weaver; - -import org.aspectj.weaver.tools.DefaultTrace; -import org.aspectj.weaver.tools.Jdk14Trace; - -public class Jdk14TraceTest extends AbstractTraceTest { - - protected void setUp() throws Exception { - super.setUp(); - trace = new Jdk14Trace(getClass()); - trace.setTraceEnabled(true); - } - - public void testJdk14Trace() { - new Jdk14Trace(getClass()); - } - - public void testSetTraceEnabled() { - DefaultTrace trace = new DefaultTrace(getClass()); - trace.setTraceEnabled(true); - assertTrue(trace.isTraceEnabled()); - } - -} diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/JoinPointSignatureIteratorTests.java b/weaver5/java5-testsrc/org/aspectj/weaver/JoinPointSignatureIteratorTests.java deleted file mode 100644 index 9b7aa00d6..000000000 --- a/weaver5/java5-testsrc/org/aspectj/weaver/JoinPointSignatureIteratorTests.java +++ /dev/null @@ -1,107 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2009 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Andy Clement - * ******************************************************************/ -package org.aspectj.weaver; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import junit.framework.TestCase; - -import org.aspectj.weaver.reflect.ReflectionWorld; - -/** - * @author Andy Clement - */ -public class JoinPointSignatureIteratorTests extends TestCase { - - private World getWorld() { - return new ReflectionWorld(getClass().getClassLoader()); - } - - /** - * Checking the signatures for a dynamic proxy - which is created using erased information and so is completely generics unaware - */ - public void testPr268419() { - World w = getWorld(); - w.setBehaveInJava5Way(true); - - // The proxy class here is not generated, it is simply loaded up. $Proxy1 is in the java5-testsrc folder, but it - // obeys the rules of a generated proxy in that it extends java.lang.reflect.Proxy - ResolvedType proxy = UnresolvedType.forName("$Proxy1").resolve(w); - assertNotNull(proxy); - - // The test hierarchy here (messageservice and genericservice) contains 2 methods. One is generic - // and one is not. The aim of the test here is that the join point signatures generated for both - // should be the same because of the use of a proxy. - - List l = proxy.getMethodsWithoutIterator(false, false, false); - for (Object object : l) { - ResolvedMember rm = (ResolvedMember) object; - if (expectedResults.containsKey(rm.toString())) { - System.out.println("\nChecking: " + rm); - int i = 0; - List/* String */sigs = (List) expectedResults.get(rm.toString()); - Iterator jpsi = rm.getJoinPointSignatures(w); - while (jpsi.hasNext()) { - ResolvedMember sig = (ResolvedMember) jpsi.next(); - assertEquals(sigs.get(i).toString(), sig.toString()); - i++; - } - if (i != sigs.size()) { - fail("Expected " + sigs.size() + " signatures but got " + i); - } - } else { - if (rm.getName().equals("get1") || rm.getName().equals("get2")) { - fail("\nFound this unchecked get method " + rm); - // Iterator jpsi = rm.getJoinPointSignatures(w); - // while (jpsi.hasNext()) { - // ResolvedMember sig = (ResolvedMember) jpsi.next(); - // System.out.println(sig); - // } - } - } - } - } - - public static Map expectedResults = new HashMap(); - - static { - List sigs = new ArrayList(); - sigs.add("java.lang.Object $Proxy1.get1(java.io.Serializable)"); - sigs.add("java.lang.Object MessageService.get1(java.io.Serializable)"); - sigs.add("java.lang.Object GenericService.get1(java.io.Serializable)"); - sigs.add("java.lang.Object GenericService.get1(java.io.Serializable)"); - expectedResults.put("java.lang.Object $Proxy1.get1(java.io.Serializable)", sigs); - - sigs = new ArrayList(); - sigs.add("java.lang.Object $Proxy1.get2(java.io.Serializable)"); - sigs.add("java.lang.Object MessageService.get2(java.io.Serializable)"); - sigs.add("java.lang.Object GenericService.get2(java.io.Serializable)"); - sigs.add("java.lang.Object GenericService.get2(java.io.Serializable)"); - expectedResults.put("java.lang.Object $Proxy1.get2(java.io.Serializable)", sigs); - - sigs = new ArrayList(); - sigs.add("java.lang.Object $Proxy1.get1(java.lang.Long)"); - expectedResults.put("java.lang.Object $Proxy1.get1(java.lang.Long)", sigs); - - sigs = new ArrayList(); - sigs.add("java.lang.Object GenericService.get1(java.io.Serializable)"); - expectedResults.put("java.lang.Object GenericService.get1(java.io.Serializable)", sigs); - - sigs = new ArrayList(); - sigs.add("java.lang.Object GenericService.get2(java.io.Serializable)"); - expectedResults.put("java.lang.Object GenericService.get2(java.io.Serializable)", sigs); - } -} diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/MemberTestCase15.java b/weaver5/java5-testsrc/org/aspectj/weaver/MemberTestCase15.java deleted file mode 100644 index f44095a0e..000000000 --- a/weaver5/java5-testsrc/org/aspectj/weaver/MemberTestCase15.java +++ /dev/null @@ -1,155 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.weaver; - -import org.aspectj.weaver.bcel.BcelWorld; - -import junit.framework.TestCase; - -/** - * @author colyer - * @author clement - */ -public class MemberTestCase15 extends TestCase { - - public void testCanBeParameterizedRegularMethod() { - BcelWorld world = new BcelWorld(); - ResolvedType javaLangClass = world.resolve(UnresolvedType.forName("java/lang/Class")); - ResolvedMember[] methods = javaLangClass.getDeclaredMethods(); - ResolvedMember getAnnotations = null; - for (int i = 0; i < methods.length; i++) { - if (methods[i].getName().equals("getAnnotations")) { - getAnnotations = methods[i]; - break; - } - } - if (getAnnotations != null) { // so can run on non-Java 5 -// System.out.println("got it"); - assertFalse(getAnnotations.canBeParameterized()); - } - } - - public void testCanBeParameterizedGenericMethod() { - BcelWorld world = new BcelWorld(); - world.setBehaveInJava5Way(true); - ResolvedType javaLangClass = world.resolve(UnresolvedType.forName("java.lang.Class")); - javaLangClass = javaLangClass.getGenericType(); - if (javaLangClass == null) return; // for < 1.5 - ResolvedMember[] methods = javaLangClass.getDeclaredMethods(); - ResolvedMember asSubclass = null; - for (int i = 0; i < methods.length; i++) { - if (methods[i].getName().equals("asSubclass")) { - asSubclass = methods[i]; - break; - } - } - if (asSubclass != null) { // so can run on non-Java 5 -// System.out.println("got it"); - assertTrue(asSubclass.canBeParameterized()); - } - } - - public void testCanBeParameterizedMethodInGenericType() { - BcelWorld world = new BcelWorld(); - world.setBehaveInJava5Way(true); - ResolvedType javaUtilList = world.resolve(UnresolvedType.forName("java.util.List")); - javaUtilList = javaUtilList.getGenericType(); - if (javaUtilList == null) return; // for < 1.5 - ResolvedMember[] methods = javaUtilList.getDeclaredMethods(); - ResolvedMember add = null; - for (int i = 0; i < methods.length; i++) { - if (methods[i].getName().equals("add")) { - add = methods[i]; - break; - } - } - if (add != null) { // so can run on non-Java 5 -// System.out.println("got it"); - assertTrue(add.canBeParameterized()); - } - } - /* - public void testGenericReferenceTypeCreation() { - UnresolvedType genericType = UnresolvedType.forGenericTypeSignature("Lorg/aspectj/weaver/MemberTestCase15$One;","Ljava/lang/Object;"); - assertEquals("Porg/aspectj/weaver/MemberTestCase15$One;",genericType.getSignature()); - assertEquals("Lorg/aspectj/weaver/MemberTestCase15$One;",genericType.getErasureSignature()); - } - - public void testMemberSignatureCreation() { - World world = new BcelWorld("../weaver5/bin/"); - //new ReflectionWorld(false, getClass().getClassLoader()); - world.setBehaveInJava5Way(true); - ResolvedType one = world.resolve("org.aspectj.weaver.MemberTestCase15$One"); - assertNotNull(one); - assertFalse(one.isMissing()); - - // Look at the methods on the parameterized type One - ResolvedMember member = findMethod("getter",one); - String erasedSignature = MemberImpl.typesToSignature(member.getReturnType(),member.getParameterTypes(),true); - assertEquals("()Ljava/lang/String;",erasedSignature); - String nonErasedSignature = MemberImpl.typesToSignature(member.getReturnType(),member.getParameterTypes(),false); - assertEquals("()Ljava/lang/String;",nonErasedSignature); - erasedSignature = MemberImpl.typesToSignature(member.getReturnType(),member.getParameterTypes(),true); - assertEquals("()Ljava/lang/String;",erasedSignature); - nonErasedSignature = MemberImpl.typesToSignature(member.getReturnType(),member.getParameterTypes(),false); - assertEquals("()Ljava/lang/String;",nonErasedSignature); - - member = findMethod("getterTwo",one); - erasedSignature = MemberImpl.typesToSignature(member.getReturnType(),member.getParameterTypes(),true); - assertEquals("()Ljava/util/List;",erasedSignature); - nonErasedSignature = MemberImpl.typesToSignature(member.getReturnType(),member.getParameterTypes(),false); - assertEquals("()Pjava/util/List;",nonErasedSignature); - nonErasedSignature = MemberImpl.typesToSignature(member.getGenericReturnType(),member.getGenericParameterTypes(),true); - assertEquals("()Ljava/util/List;",nonErasedSignature); - nonErasedSignature = MemberImpl.typesToSignature(member.getGenericReturnType(),member.getGenericParameterTypes(),false); - assertEquals("()Pjava/util/List;",nonErasedSignature); - - // Grab the generic type backing the parameterized type - ResolvedType oneGeneric = one.getGenericType(); - assertTrue(oneGeneric.isGenericType()); - member = findMethod("getterTwo",oneGeneric); - erasedSignature = MemberImpl.typesToSignature(member.getReturnType(),member.getParameterTypes(),true); - assertEquals("()Ljava/util/List;",erasedSignature); - erasedSignature = MemberImpl.typesToSignature(member.getReturnType(),member.getParameterTypes(),false); - assertEquals("()Ljava/util/List;",erasedSignature); - nonErasedSignature = MemberImpl.typesToSignature(member.getReturnType(),member.getParameterTypes(),false); - assertEquals("()Pjava/util/List;",nonErasedSignature); - nonErasedSignature = MemberImpl.typesToSignature(member.getGenericReturnType(),member.getGenericParameterTypes(),false); - assertEquals("()Ljava/util/List;",nonErasedSignature); - - - ResolvedType oneRaw = oneGeneric.getRawType(); - member = findMethod("getterTwo",oneRaw); - } - - private ResolvedMember findMethod(String name, ResolvedType type) { - ResolvedMember[] members = type.getDeclaredMethods(); - for (ResolvedMember member: members) { - if (member.getName().equals(name)) { - return member; - } - } - return null; - } - - // testcode - class One { - T t; - T getter() { - return null; - } - List getterTwo() { - return null; - } - } - */ -} diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/ReferenceTypeTestCase.java b/weaver5/java5-testsrc/org/aspectj/weaver/ReferenceTypeTestCase.java deleted file mode 100644 index 5fbc530e7..000000000 --- a/weaver5/java5-testsrc/org/aspectj/weaver/ReferenceTypeTestCase.java +++ /dev/null @@ -1,854 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.weaver; - -import java.rmi.RemoteException; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -import junit.framework.TestCase; - -import org.aspectj.util.PartialOrder; -import org.aspectj.weaver.bcel.BcelWorld; - -// test cases for Adrian's additions to ReferenceType -// XXX - couldn't find any unit test cases for the rest of the ReferenceType class -public class ReferenceTypeTestCase extends TestCase { - - public void testIsRawTrue() { - BcelWorld world = new BcelWorld(); - world.setBehaveInJava5Way(true); - UnresolvedType javaLangClass = UnresolvedType.forName("java.lang.Class"); - ResolvedType rtx = world.resolve(javaLangClass); - assertTrue("Resolves to reference type", (rtx instanceof ReferenceType)); - ReferenceType rt = (ReferenceType) rtx; - assertTrue("java.lang.Class is raw", rt.isRawType()); - } - - public void testIsRawFalse() { - BcelWorld world = new BcelWorld(); - world.setBehaveInJava5Way(true); - UnresolvedType javaLangObject = UnresolvedType.forName("java.lang.Object"); - ResolvedType rtx = world.resolve(javaLangObject); - assertTrue("Resolves to reference type", (rtx instanceof ReferenceType)); - ReferenceType rt = (ReferenceType) rtx; - assertFalse("java.lang.Object is not raw", rt.isRawType()); - } - - public void testIsGenericTrue() { - BcelWorld world = new BcelWorld(); - world.setBehaveInJava5Way(true); - UnresolvedType javaLangClass = UnresolvedType.forName("java.lang.Class"); - ResolvedType rtx = world.resolve(javaLangClass); - assertTrue("java.lang.Class has underpinning generic type", rtx.getGenericType().isGenericType()); - } - - public void testIsGenericFalse() { - BcelWorld world = new BcelWorld(); - world.setBehaveInJava5Way(true); - UnresolvedType javaLangObject = UnresolvedType.forName("java.lang.Object"); - ResolvedType rtx = world.resolve(javaLangObject); - assertFalse(rtx.isGenericType()); - } - - BcelWorld world; - - @Override - public void setUp() throws Exception { - super.setUp(); - world = new BcelWorld(); - world.setBehaveInJava5Way(true); - } - - public void testCoercion01() { - ReferenceType listOfString = (ReferenceType) world.resolve(UnresolvedType - .forSignature("Pjava/util/List;")); - ReferenceType listOfInteger = (ReferenceType) world.resolve(UnresolvedType - .forSignature("Pjava/util/List;")); - assertFalse(listOfInteger.isAssignableFrom(listOfString)); - assertFalse(listOfString.isAssignableFrom(listOfInteger)); - assertFalse(listOfInteger.isCoerceableFrom(listOfString)); - assertFalse(listOfString.isCoerceableFrom(listOfInteger)); - } - - public void testAssignable01() { - List list = new ArrayList(); - List listOfString = new ArrayList(); - List listOfSomething = new ArrayList(); - List listOfSomethingNumberish = new ArrayList(); - List listOfSomethingSuperDouble = new ArrayList(); - // interfaces too List - - ReferenceType ajList = resolve("Ljava/util/List;"); - ReferenceType ajListOfString = resolve("Pjava/util/List;"); - ReferenceType ajListOfSomething = resolve("Pjava/util/List<*>;"); - ReferenceType ajListOfSomethingNumberish = resolve("Pjava/util/List<+Ljava/lang/Number;>;"); - ReferenceType ajListOfSomethingSuperDouble = resolve("Pjava/util/List<-Ljava/lang/Double;>;"); - - // try and write the java equivalent, if it succeeds then check isAssignableFrom() is true - // if the java is only correct with a cast, check isCoerceableFrom() - list = listOfString; - assertTrue(ajList.isAssignableFrom(ajListOfString)); - list = listOfSomething; - assertTrue(ajList.isAssignableFrom(ajListOfSomething)); - list = listOfSomethingNumberish; - assertTrue(ajList.isAssignableFrom(ajListOfSomething)); - list = listOfSomethingSuperDouble; - assertTrue(ajList.isAssignableFrom(ajListOfSomethingSuperDouble)); - - listOfString = list; // unchecked conversion to List - assertFalse(ajListOfString.isAssignableFrom(ajList)); - assertTrue(ajListOfString.isCoerceableFrom(ajListOfSomething)); - // error: listOfString = listOfSomething; - assertFalse(ajListOfString.isAssignableFrom(ajListOfSomething)); - // error: listOfString = listOfSomethingNumberish; - assertFalse(ajListOfString.isAssignableFrom(ajListOfSomethingNumberish)); - // error: listOfString = listOfSomethingSuperDouble; - assertFalse(ajListOfString.isAssignableFrom(ajListOfSomethingSuperDouble)); - // error: listOfString = (List) listOfSomethingSuperDouble; - assertFalse(ajListOfString.isCoerceableFrom(ajListOfSomethingSuperDouble)); - - listOfSomething = list; - assertTrue(ajListOfSomething.isAssignableFrom(ajList)); - listOfSomething = listOfString; - assertTrue(ajListOfSomething.isAssignableFrom(ajListOfString)); - listOfSomething = listOfSomethingNumberish; - assertTrue(ajListOfSomething.isAssignableFrom(ajListOfSomething)); - listOfSomething = listOfSomethingSuperDouble; - assertTrue(ajListOfSomething.isAssignableFrom(ajListOfSomethingSuperDouble)); - - listOfSomethingNumberish = list; // unchecked conversion - assertFalse(ajListOfSomethingNumberish.isAssignableFrom(ajList)); - assertTrue(ajListOfSomethingNumberish.isCoerceableFrom(ajList)); - // error: listOfSomethingNumberish = listOfString; - assertFalse(ajListOfSomethingNumberish.isAssignableFrom(ajListOfString)); - assertFalse(ajListOfSomethingNumberish.isCoerceableFrom(ajListOfString)); - // error: listOfSomethingNumberish = listOfSomething; - assertFalse(ajListOfSomethingNumberish.isAssignableFrom(ajListOfSomething)); - listOfSomethingNumberish = (List) listOfSomething; - assertTrue(ajListOfSomethingNumberish.isCoerceableFrom(ajListOfSomething)); - // error: listOfSomethingNumberish = listOfSomethingSuperDouble; - assertFalse(ajListOfSomethingNumberish.isAssignableFrom(ajListOfSomethingSuperDouble)); - // listOfSomethingNumberish = (List) listOfSomethingSuperDouble; - // assertTrue(ajListOfSomethingNumberish.isCoerceableFrom(ajListOfSomethingSuperDouble)); - } - - class C { - void m1(List e) { - } - - void m2(List e) { - } - - void m3(List e) { - } - - void m4(List e) { - } - - void m5(List e) { - } - - void m6(List e) { - } - - void m7(List> e) { - } - - void m8(List e) { - } - - void m9(E e) { - } - } - - class A1 { - } - - class B1 extends A1 { - } - - class C1 extends B1 { - } - - class D1 extends C1 { - } - - class D2 { - void m5(List e) { - } - } - - public void testAssignable02() { - List list = new ArrayList(); - ArrayList arraylist = null; - List listOfString = new ArrayList(); - List listOfSomething = new ArrayList(); - ArrayList arrayListOfSomething = null; - List listOfNumber = null; - ArrayList arrayListOfNumber = null; - ArrayList arrayListOfSomethingNumberish = null; - List listOfSomethingNumberish = new ArrayList(); - List listOfSomethingSuperDouble = new ArrayList(); - List listOfInteger = new ArrayList(); - ArrayList arrayListOfString; - ArrayList arraylistOfInteger; - // interfaces too List - - ReferenceType ajArrayListOfString = resolve("Pjava/util/ArrayList;"); - ReferenceType ajArrayListOfInteger = resolve("Pjava/util/ArrayList;"); - ReferenceType ajArrayListOfNumber = resolve("Pjava/util/ArrayList;"); - ReferenceType ajArrayListOfSomethingNumberish = resolve("Pjava/util/ArrayList<+Ljava/lang/Number;>;"); - ReferenceType ajList = resolve("Ljava/util/List;"); - ReferenceType ajArrayList = resolve("Ljava/util/ArrayList;"); - ReferenceType ajListOfString = resolve("Pjava/util/List;"); - ReferenceType ajListOfSomething = resolve("Pjava/util/List<*>;"); - ReferenceType ajArrayListOfSomething = resolve("Pjava/util/ArrayList<*>;"); - ReferenceType ajListOfSomethingNumberish = resolve("Pjava/util/List<+Ljava/lang/Number;>;"); - ReferenceType ajListOfSomethingSuperDouble = resolve("Pjava/util/List<-Ljava/lang/Double;>;"); - ReferenceType ajListOfInteger = resolve("Pjava/util/List;"); - ReferenceType ajListOfNumber = resolve("Pjava/util/List;"); - // Effectively, whether the advice matches is based on whether what we pass at the joinpoint could - // be bound to the specification in the args() pointcut - - // void around(): execution(* C.m1(..)) && args(List){} //: Should match (it does) - assertTrue(ajListOfInteger.isAssignableFrom(ajListOfInteger)); - - // void around(): execution(* C.m1(..)) && args(ArrayList){}//: Should runtime check (it does!) - ArrayList x = (ArrayList) listOfInteger; - assertFalse(ajArrayListOfInteger.isAssignableFrom(ajListOfInteger)); - assertTrue(ajArrayListOfInteger.isCoerceableFrom(ajListOfInteger)); - - // void around(): execution(* C.m1(..)) && args(List){} // Should not match (it does not!) - // error: listOfNumber = listOfInteger; - assertFalse(ajListOfNumber.isAssignableFrom(ajListOfInteger)); - assertFalse(ajListOfNumber.isCoerceableFrom(ajListOfInteger)); - - // void around(): execution(* C.m1(..)) && args(ArrayList){} // Should not match (it does not) - // error: arrayListOfNumber = listOfInteger; - assertFalse(ajArrayListOfNumber.isAssignableFrom(ajListOfInteger)); - assertFalse(ajArrayListOfNumber.isCoerceableFrom(ajListOfInteger)); - - // void around(): execution(* C.m1(..)) && args(List){} // Should match (it does) - listOfSomethingNumberish = listOfInteger; - assertTrue(ajListOfSomethingNumberish.isAssignableFrom(ajListOfInteger)); - - // void around(): execution(* C.m1(..)) && args(ArrayList){}// Should runtime check (it does!) - arrayListOfSomethingNumberish = (ArrayList) listOfInteger; - assertFalse(ajArrayListOfSomethingNumberish.isAssignableFrom(ajListOfInteger)); - assertTrue(ajArrayListOfSomethingNumberish.isCoerceableFrom(ajListOfInteger)); - - // void around(): execution(* C.m1(..)) && args(List){}// Should match (it does) - list = listOfInteger; - assertTrue(ajList.isAssignableFrom(ajListOfInteger)); - - // void around(): execution(* C.m1(..)) && args(ArrayList){}//: Should runtime check (it does not match!) - arraylist = (ArrayList) listOfInteger; - assertFalse(ajArrayList.isAssignableFrom(ajListOfInteger)); - assertTrue(ajArrayList.isCoerceableFrom(ajListOfInteger)); - - // void around(): execution(* C.m1(..)) && args(List){}// Should match (it does) - listOfSomething = listOfInteger; - assertTrue(ajListOfSomething.isAssignableFrom(ajListOfInteger)); - - // void around(): execution(* C.m1(..)) && args(ArrayList){}// Should runtime check (it does not match!) - arrayListOfSomething = (ArrayList) listOfInteger; - assertFalse(ajArrayListOfSomething.isAssignableFrom(ajListOfInteger)); - assertTrue(ajArrayListOfSomething.isCoerceableFrom(ajListOfInteger)); - - // void around(): execution(* C.m1(..)) && args(ArrayList){}// Should not match (it does not match!) - // error: arrayListOfString = listOfInteger; - assertFalse(ajArrayListOfString.isAssignableFrom(ajListOfInteger)); - assertFalse(ajArrayListOfString.isCoerceableFrom(ajListOfInteger)); - } - - public void testAssignable03_method_m2() { - List list = new ArrayList(); - ArrayList arraylist = null; - List listOfString = new ArrayList(); - List listOfSomething = new ArrayList(); - ArrayList arrayListOfSomething = null; - List listOfNumber = null; - ArrayList arrayListOfNumber = null; - ArrayList arrayListOfInteger = null; - ArrayList arrayListOfSomethingNumberish = null; - List listOfSomethingNumberish = new ArrayList(); - List listOfSomethingSuperDouble = new ArrayList(); - List listOfInteger = new ArrayList(); - ArrayList arrayListOfString; - ArrayList arraylistOfInteger; - // interfaces too List - - ReferenceType ajArrayListOfString = resolve("Pjava/util/ArrayList;"); - ReferenceType ajArrayListOfInteger = resolve("Pjava/util/ArrayList;"); - ReferenceType ajArrayListOfNumber = resolve("Pjava/util/ArrayList;"); - ReferenceType ajArrayListOfSomethingNumberish = resolve("Pjava/util/ArrayList<+Ljava/lang/Number;>;"); - ReferenceType ajList = resolve("Ljava/util/List;"); - ReferenceType ajArrayList = resolve("Ljava/util/ArrayList;"); - ReferenceType ajListOfString = resolve("Pjava/util/List;"); - ReferenceType ajListOfSomething = resolve("Pjava/util/List<*>;"); - ReferenceType ajArrayListOfSomething = resolve("Pjava/util/ArrayList<*>;"); - ReferenceType ajListOfSomethingNumberish = resolve("Pjava/util/List<+Ljava/lang/Number;>;"); - ReferenceType ajListOfSomethingSuperDouble = resolve("Pjava/util/List<-Ljava/lang/Double;>;"); - ReferenceType ajListOfInteger = resolve("Pjava/util/List;"); - ReferenceType ajListOfNumber = resolve("Pjava/util/List;"); - - // void m2(List e) {} - - // comment 11 - // void around(): execution(* C.m2(..)) && args(List){} //: Should not match (but it does) ERROR - listOfInteger = (List) listOfSomethingNumberish; - assertFalse(ajListOfInteger.isAssignableFrom(ajListOfSomethingNumberish)); - assertTrue(ajListOfInteger.isCoerceableFrom(ajListOfSomethingNumberish)); - - // void around(): execution(* C.m2(..)) && args(ArrayList){}//: Should not match (but it does!) ERROR - arrayListOfInteger = (ArrayList) listOfSomethingNumberish; - assertFalse(ajArrayListOfInteger.isAssignableFrom(ajListOfSomethingNumberish)); - assertTrue(ajArrayListOfInteger.isCoerceableFrom(ajListOfSomethingNumberish)); - - // void around(): execution(* C.m2(..)) && args(List){} //: Should not match (but it does) ERROR - listOfNumber = (List) listOfSomethingNumberish; - assertFalse(ajListOfNumber.isAssignableFrom(ajListOfSomethingNumberish)); - assertTrue(ajListOfNumber.isCoerceableFrom(ajListOfSomethingNumberish)); - - // void around(): execution(* C.m2(..)) && args(ArrayList){}//: Should not runtime check (but it does!) ERROR - arrayListOfNumber = (ArrayList) listOfSomethingNumberish; - assertFalse(ajArrayListOfNumber.isAssignableFrom(ajListOfSomethingNumberish)); - assertTrue(ajArrayListOfNumber.isCoerceableFrom(ajListOfSomethingNumberish)); - - // void around(): execution(* C.m2(..)) && args(List){}//: Should match (it does) - listOfSomethingNumberish = listOfSomethingNumberish; - assertTrue(ajListOfSomethingNumberish.isAssignableFrom(ajListOfSomethingNumberish)); - - // void around(): execution(* C.m2(..)) && args(ArrayList){}//: Should runtime check (it does!) - arrayListOfSomethingNumberish = (ArrayList) listOfSomethingNumberish; - assertFalse(ajArrayListOfSomethingNumberish.isAssignableFrom(ajListOfSomethingNumberish)); - assertTrue(ajArrayListOfSomethingNumberish.isCoerceableFrom(ajListOfSomethingNumberish)); - - // void around(): execution(* C.m2(..)) && args(List){}//: Should match (it does) - list = listOfSomethingNumberish; - assertTrue(ajList.isAssignableFrom(ajListOfSomethingNumberish)); - - // void around(): execution(* C.m2(..)) && args(ArrayList){}//: Should runtime check (it does not match!) ERROR - arraylist = (ArrayList) listOfSomethingNumberish; - assertFalse(ajArrayList.isAssignableFrom(ajListOfSomethingNumberish)); - assertTrue(ajArrayList.isCoerceableFrom(ajListOfSomethingNumberish)); - - // void around(): execution(* C.m2(..)) && args(List){}//: Should match (it does) - listOfSomething = listOfSomethingNumberish; - assertTrue(ajListOfSomething.isAssignableFrom(ajListOfSomethingNumberish)); - - // void around(): execution(* C.m2(..)) && args(ArrayList){}//: Should runtime check (it does!) - arrayListOfSomething = (ArrayList) listOfSomethingNumberish; - assertFalse(ajArrayListOfSomething.isAssignableFrom(ajListOfSomethingNumberish)); - assertTrue(ajArrayListOfSomething.isCoerceableFrom(ajListOfSomethingNumberish)); - - // void around(): execution(* C.m2(..)) && args(ArrayList){}//: Should not match (it does not match!) - // error: arrayListOfString = listOfSomethingNumberish; - assertFalse(ajArrayListOfString.isAssignableFrom(ajListOfSomethingNumberish)); - assertFalse(ajArrayListOfString.isCoerceableFrom(ajListOfSomethingNumberish)); - } - - public void testAssignable04_method_m3() { - List list = new ArrayList(); - ArrayList arraylist = null; - List listOfString = new ArrayList(); - List listOfSomething = new ArrayList(); - ArrayList arrayListOfSomething = null; - List listOfNumber = null; - ArrayList arrayListOfNumber = null; - ArrayList arrayListOfInteger = null; - ArrayList arrayListOfSomethingNumberish = null; - List listOfSomethingNumberish = new ArrayList(); - List listOfSomethingSuperDouble = new ArrayList(); - List listOfInteger = new ArrayList(); - ArrayList arrayList = null; - ArrayList arrayListOfString; - ArrayList arraylistOfInteger; - // interfaces too List - - ReferenceType ajArrayListOfString = resolve("Pjava/util/ArrayList;"); - ReferenceType ajArrayListOfInteger = resolve("Pjava/util/ArrayList;"); - ReferenceType ajArrayListOfNumber = resolve("Pjava/util/ArrayList;"); - ReferenceType ajArrayListOfSomethingNumberish = resolve("Pjava/util/ArrayList<+Ljava/lang/Number;>;"); - ReferenceType ajList = resolve("Ljava/util/List;"); - ReferenceType ajArrayList = resolve("Ljava/util/ArrayList;"); - ReferenceType ajListOfString = resolve("Pjava/util/List;"); - ReferenceType ajListOfSomething = resolve("Pjava/util/List<*>;"); - ReferenceType ajArrayListOfSomething = resolve("Pjava/util/ArrayList<*>;"); - ReferenceType ajListOfSomethingNumberish = resolve("Pjava/util/List<+Ljava/lang/Number;>;"); - ReferenceType ajListOfSomethingSuperDouble = resolve("Pjava/util/List<-Ljava/lang/Double;>;"); - ReferenceType ajListOfInteger = resolve("Pjava/util/List;"); - ReferenceType ajListOfNumber = resolve("Pjava/util/List;"); - - // void m3(List e) { } - - // void around(): execution(* C.m3(..)) && args(List){} //: Should not match (it does not) - // error: listOfInteger = listOfNumber; - assertFalse(ajListOfInteger.isAssignableFrom(ajListOfNumber)); - assertFalse(ajListOfInteger.isCoerceableFrom(ajListOfNumber)); - - // void around(): execution(* C.m3(..)) && args(ArrayList){}//: Should not match (it does not) - // error: arrayListOfInteger = listOfNumber; - assertFalse(ajArrayListOfInteger.isAssignableFrom(ajListOfNumber)); - assertFalse(ajArrayListOfInteger.isCoerceableFrom(ajListOfNumber)); - - // void around(): execution(* C.m3(..)) && args(List){}//: Should match (it does) - listOfNumber = listOfNumber; - assertTrue(ajListOfNumber.isAssignableFrom(ajListOfNumber)); - - // void around(): execution(* C.m3(..)) && args(ArrayList){}//: Should runtime match (it does) - arrayListOfNumber = (ArrayList) listOfNumber; - assertFalse(ajArrayListOfNumber.isAssignableFrom(ajListOfNumber)); - assertTrue(ajArrayListOfNumber.isCoerceableFrom(ajListOfNumber)); - - // void around(): execution(* C.m3(..)) && args(List){}//: Should match (it does) - listOfSomethingNumberish = listOfNumber; - assertTrue(ajListOfSomethingNumberish.isAssignableFrom(ajListOfNumber)); - - // void around(): execution(* C.m3(..)) && args(ArrayList){}//: Should runtime check (it does!) - arrayListOfSomethingNumberish = (ArrayList) listOfNumber; - assertFalse(ajArrayListOfSomethingNumberish.isAssignableFrom(ajListOfNumber)); - assertTrue(ajArrayListOfSomethingNumberish.isCoerceableFrom(ajListOfNumber)); - - // void around(): execution(* C.m3(..)) && args(List){}//: Should match (it does) - list = listOfNumber; - assertTrue(ajList.isAssignableFrom(ajListOfNumber)); - - // void around(): execution(* C.m3(..)) && args(ArrayList){}//: Should runtime check (it does not match!) ERROR - arrayList = (ArrayList) listOfNumber; - assertFalse(ajArrayList.isAssignableFrom(ajListOfNumber)); - assertTrue(ajArrayList.isCoerceableFrom(ajListOfNumber)); - - // void around(): execution(* C.m3(..)) && args(List){}//: Should match (it does) - listOfSomething = listOfNumber; - assertTrue(ajListOfSomething.isAssignableFrom(ajListOfNumber)); - - // void around(): execution(* C.m3(..)) && args(ArrayList){}//: Should runtime check (it does!) - arrayListOfSomething = (ArrayList) listOfNumber; - assertFalse(ajArrayListOfSomething.isAssignableFrom(ajListOfNumber)); - assertTrue(ajArrayListOfSomething.isCoerceableFrom(ajListOfNumber)); - - // void around(): execution(* C.m3(..)) && args(ArrayList){}//: Should not match (it does not match!) - // error: arrayListOfString = listOfNumber; - assertFalse(ajArrayListOfString.isAssignableFrom(ajListOfNumber)); - assertFalse(ajArrayListOfString.isCoerceableFrom(ajListOfNumber)); - - } - - static class ClassA { - } - - static interface IMarker { - } - - static class ClassB implements IMarker> { - } - - static class ClassC implements IMarker { - } - - public void testAssignability_pr267559() { - ClassB cb = new ClassB(); - ClassB cb2 = new ClassB(); - - ReferenceType rcb = resolve("Lorg/aspectj/weaver/ReferenceTypeTestCase$ClassB;"); - ReferenceType rcb2 = resolve("Lorg/aspectj/weaver/ReferenceTypeTestCase$ClassB;"); - boolean b = rcb.isAssignableFrom(rcb2); - assertTrue(b); - b = rcb2.isAssignableFrom(rcb); - assertTrue(b); - - rcb = resolve("Porg/aspectj/weaver/ReferenceTypeTestCase$IMarker;>;"); - rcb2 = resolve("Lorg/aspectj/weaver/ReferenceTypeTestCase$ClassB;"); - b = rcb.isAssignableFrom(rcb2); - assertTrue(b); - } - - public void testAssignable03_method_m4() { - List list = new ArrayList(); - ArrayList arraylist = null; - List listOfString = new ArrayList(); - List listOfSomething = new ArrayList(); - ArrayList arrayListOfSomething = null; - List listOfNumber = null; - ArrayList arrayListOfNumber = null; - ArrayList arrayListOfSomethingNumberish = null; - List listOfSomethingNumberish = new ArrayList(); - List listOfSomethingSuperDouble = new ArrayList(); - List listOfInteger = new ArrayList(); - ArrayList arrayListOfString; - ArrayList arraylistOfInteger; - // interfaces too List - - ReferenceType ajArrayListOfString = resolve("Pjava/util/ArrayList;"); - ReferenceType ajArrayListOfInteger = resolve("Pjava/util/ArrayList;"); - ReferenceType ajArrayListOfNumber = resolve("Pjava/util/ArrayList;"); - ReferenceType ajArrayListOfSomethingNumberish = resolve("Pjava/util/ArrayList<+Ljava/lang/Number;>;"); - ReferenceType ajList = resolve("Ljava/util/List;"); - ReferenceType ajArrayList = resolve("Ljava/util/ArrayList;"); - ReferenceType ajListOfString = resolve("Pjava/util/List;"); - ReferenceType ajListOfSomething = resolve("Pjava/util/List<*>;"); - ReferenceType ajArrayListOfSomething = resolve("Pjava/util/ArrayList<*>;"); - ReferenceType ajListOfSomethingNumberish = resolve("Pjava/util/List<+Ljava/lang/Number;>;"); - ReferenceType ajListOfSomethingSuperDouble = resolve("Pjava/util/List<-Ljava/lang/Double;>;"); - ReferenceType ajListOfInteger = resolve("Pjava/util/List;"); - ReferenceType ajListOfNumber = resolve("Pjava/util/List;"); - - // void m4(List e) {} - - // void around(): execution(* C.m4(..)) && args(List){} //: Should match with unchecked warning - listOfInteger = (List) listOfSomething; - assertFalse(ajListOfInteger.isAssignableFrom(ajListOfSomething)); - assertTrue(ajListOfInteger.isCoerceableFrom(ajListOfSomething)); - - // void around(): execution(* C.m4(..)) && args(ArrayList){} // Should match with unchecked warning - arraylistOfInteger = (ArrayList) listOfSomething; - assertFalse(ajArrayListOfInteger.isAssignableFrom(ajListOfSomething)); - assertTrue(ajArrayListOfInteger.isCoerceableFrom(ajListOfSomething)); - - // void around(): execution(* C.m4(..)) && args(List){} // Should match with unchecked warning - listOfNumber = (List) listOfSomething; - assertFalse(ajListOfNumber.isAssignableFrom(ajListOfSomething)); - assertTrue(ajListOfNumber.isCoerceableFrom(ajListOfSomething)); - - // void around(): execution(* C.m4(..)) && args(ArrayList){} // Should match with unchecked warning - arrayListOfNumber = (ArrayList) listOfSomething; - assertFalse(ajArrayListOfNumber.isAssignableFrom(ajListOfSomething)); - assertTrue(ajArrayListOfNumber.isCoerceableFrom(ajListOfSomething)); - - // void around(): execution(* C.m4(..)) && args(List){} // Should match with unchecked warning - listOfSomethingNumberish = (List) listOfSomething; - assertFalse(ajListOfSomethingNumberish.isAssignableFrom(ajListOfSomething)); - assertTrue(ajListOfSomethingNumberish.isCoerceableFrom(ajListOfSomething)); - - // void around(): execution(* C.m4(..)) && args(ArrayList){} // Should match with unchecked warning - arrayListOfSomethingNumberish = (ArrayList) listOfSomething; - assertFalse(ajArrayListOfSomethingNumberish.isAssignableFrom(ajListOfSomething)); - assertTrue(ajArrayListOfSomethingNumberish.isCoerceableFrom(ajListOfSomething)); - - // void around(): execution(* C.m4(..)) && args(List){} // Should match - list = listOfSomething; - assertTrue(ajList.isAssignableFrom(ajListOfSomething)); - - // void around(): execution(* C.m4(..)) && args(ArrayList){} // Should runtime check - arraylist = (ArrayList) listOfSomething; - assertFalse(ajArrayList.isAssignableFrom(ajListOfSomething)); - assertTrue(ajArrayList.isCoerceableFrom(ajListOfSomething)); - - // void around(): execution(* C.m4(..)) && args(List){}//: Should match - list = listOfSomething; - assertTrue(ajList.isAssignableFrom(ajListOfSomething)); - - // void around(): execution(* C.m4(..)) && args(ArrayList){} // Should runtime check - arrayListOfSomething = (ArrayList) listOfSomething; - assertFalse(ajArrayListOfSomething.isAssignableFrom(ajListOfSomething)); - assertTrue(ajArrayListOfSomething.isCoerceableFrom(ajListOfSomething)); - - // void around(): execution(* C.m4(..)) && args(ArrayList){} // Should match with unchecked warning - arrayListOfString = (ArrayList) listOfSomething; - assertFalse(ajArrayListOfString.isAssignableFrom(ajListOfSomething)); - assertTrue(ajArrayListOfString.isCoerceableFrom(ajListOfSomething)); - } - - // copy of the real one in BcelClassWeaver - public static class IfaceInitList implements PartialOrder.PartialComparable { - final ResolvedType onType; - List list = new ArrayList(); - - IfaceInitList(ResolvedType onType) { - this.onType = onType; - } - - public int compareTo(Object other) { - IfaceInitList o = (IfaceInitList) other; - if (onType.isAssignableFrom(o.onType)) { - return +1; - } else if (o.onType.isAssignableFrom(onType)) { - return -1; - } else { - return 0; - } - } - - public int fallbackCompareTo(Object other) { - return 0; - } - } - - public void testExpensiveAssignableChecks_309336() { - List objects = new ArrayList(); - ReferenceType rcb = resolve("Lorg/aspectj/weaver/ReferenceTypeTestCase$Foo;"); - ReferenceType i = (ReferenceType) rcb.getDeclaredInterfaces()[0]; - while (i != null && i.isInterface()) { - objects.add(Math.abs(new Random(12).nextInt(objects.size() + 1)), new IfaceInitList(i)); - ResolvedType[] rt = i.getDeclaredInterfaces(); - i = rt == null || rt.length == 0 ? null : (ReferenceType) rt[0]; - } - for (int loop = 0; loop < 10; loop++) { - // ReferenceType.r = 0; - long stime = System.nanoTime(); - for (int j = 0; j < 10; j++) { - List objects2 = new ArrayList(); - objects2.addAll(objects); - PartialOrder.sort(objects2); - } - long etime = System.nanoTime(); - System.err.println("Took " + ((etime - stime) / 1000000) + "ms: calls ");// + ReferenceType.r); - } - // could do with asserting something... basically we are just checking we didn't run out of memory doing the sorts above! - } - - public interface Operator14 { - T execute(String aArg) throws E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11, E12, E13, E14, RemoteException; - } - - public interface Operator13 - extends Operator14 { - } - - public interface Operator12 - extends Operator13 { - } - - public interface Operator11 - extends Operator12 { - } - - public interface Operator10 - extends Operator11 { - - } - - public interface Operator9 - extends Operator10 { - } - - public interface Operator8 - extends Operator9 { - } - - public interface Operator7 - extends Operator8 { - } - - public interface Operator6 - extends Operator7 { - - } - - public interface Operator5 - extends Operator6 { - } - - public interface Operator4 extends - Operator5 { - } - - public interface Operator3 extends - Operator4 { - } - - public interface Operator2 extends Operator3 { - - } - - public interface Operator1 extends Operator2 { - } - - public interface Operator extends Operator1 { - } - - class Foo implements Operator { - public String execute(String aArg) throws NullPointerException, RemoteException { - System.out.println("Doh!"); - return aArg; - } - } - - // public void testAssignable_method_m5() { - // List list = new ArrayList(); - // ArrayList arraylist = null; - // List listOfString = new ArrayList(); - // List listOfSomething = new ArrayList(); - // ArrayList arrayListOfSomething = null; - // List listOfNumber = null; - // ArrayList arrayListOfNumber = null; - // ArrayList arrayListOfSomethingNumberish = null; - // List listOfSomethingNumberish = new ArrayList(); - // List listOfSomethingSuperDouble = new ArrayList(); - // List listOfInteger = new ArrayList(); - // ArrayList arrayListOfString; - // ArrayList arraylistOfInteger; - // // interfaces too List - // - // ReferenceType ajArrayListOfString = resolve("Pjava/util/ArrayList;"); - // ReferenceType ajArrayListOfInteger = resolve("Pjava/util/ArrayList;"); - // ReferenceType ajArrayListOfNumber = resolve("Pjava/util/ArrayList;"); - // ReferenceType ajArrayListOfSomethingNumberish = resolve("Pjava/util/ArrayList<+Ljava/lang/Number;>;"); - // ReferenceType ajList = resolve("Ljava/util/List;"); - // ReferenceType ajArrayList = resolve("Ljava/util/ArrayList;"); - // ReferenceType ajListOfString = resolve("Pjava/util/List;"); - // ReferenceType ajListOfSomething = resolve("Pjava/util/List<*>;"); - // ReferenceType ajArrayListOfSomething = resolve("Pjava/util/ArrayList<*>;"); - // ReferenceType ajListOfSomethingNumberish = resolve("Pjava/util/List<+Ljava/lang/Number;>;"); - // ReferenceType ajListOfSomethingSuperDouble = resolve("Pjava/util/List<-Ljava/lang/Double;>;"); - // ReferenceType ajListOfInteger = resolve("Pjava/util/List;"); - // ReferenceType ajListOfNumber = resolve("Pjava/util/List;"); - // ReferenceType ajListOfEextendsNumber = resolve("Pjava/util/List<+TE") - // - // // class C { - // // void m5(List e) { } - // // - // // void around(): execution(* C.m5(..)) && args(List){} Should not match (but it does) ERROR - // - // // void around(): execution(* C.m5(..)) && args(ArrayList){}//: Should not match (but it does!) ERROR - // // void around(): execution(* C.m5(..)) && args(List){}//: Should not match (but it does!) ERROR - // // void around(): execution(* C.m5(..)) && args(ArrayList){}//: Should not match (it does) ERROR - // // void around(): execution(* C.m5(..)) && args(List){}//: Should match (it does) - // // void around(): execution(* C.m5(..)) && args(ArrayList){}//: Should runtime check (it does!) - // // void around(): execution(* C.m5(..)) && args(List){}//: Should match (it does) - // // void around(): execution(* C.m5(..)) && args(ArrayList){}//: Should runtime check (it does not match!) ERROR - // // void around(): execution(* C.m5(..)) && args(List){}//: Should match (it does) - // // void around(): execution(* C.m5(..)) && args(ArrayList){}//: Should runtime check (it does not match!) - // // void around(): execution(* C.m5(..)) && args(ArrayList){}//: Should not match (it does not match!) - // // - // // // void around(): execution(* D2.m5(..)) && args(List){} //: Should - // // not match (but it does) ERROR - // // // void around(): execution(* D2.m5(..)) && args(ArrayList){}//: - // // Should not match (but it does!) ERROR - // // // void around(): execution(* D2.m5(..)) && args(List){}//: Should - // // not match (but it does!) ERROR - // // // void around(): execution(* D2.m5(..)) && args(ArrayList){}//: - // // Should not match (it does) ERROR - // // // void around(): execution(* D2.m5(..)) && args(List){}//: - // // Should match (it does) - // // // void around(): execution(* D2.m5(..)) && args(ArrayList){}//: Should runtime check (it does!) - // // // void around(): execution(* D2.m5(..)) && args(List){}//: - // // Should match (it does) - // // // void around(): execution(* D2.m5(..)) && args(ArrayList){}//: Should runtime check (it does!) - // // // void around(): execution(* D2.m5(..)) && args(List){}//: Should match - // // (it does) - // // // void around(): execution(* D2.m5(..)) && args(ArrayList){}//: Should - // // runtime check (it does not match!) ERROR - // // // void around(): execution(* D2.m5(..)) && args(List){}//: Should - // // match (it does) - // // // void around(): execution(* D2.m5(..)) && args(ArrayList){}//: - // // Should runtime check (it does not match!) - // // // void around(): execution(* D2.m5(..)) && args(ArrayList){}//: - // // Should not match (it does not match!) - // // - // // // void around(): execution(* C.m6(..)) && args(List){} //: - // // Should not match (but it does) ERROR - // // // void around(): execution(* C.m6(..)) && args(ArrayList){}//: - // // Should not match (but it does!) ERROR - // // // void around(): execution(* C.m6(..)) && args(List){}//: Should - // // not match (but it does!) ERROR - // // // void around(): execution(* C.m6(..)) && args(ArrayList){}//: - // // Should not match (it does) ERROR - // // // void around(): execution(* C.m6(..)) && args(List){}//: Should match (it does) - // // // void around(): execution(* C.m6(..)) && args(ArrayList){}//: Should runtime check (it does!) - // // // void around(): execution(* C.m6(..)) && args(List){}//: Should match - // // (it does) - // // // void around(): execution(* C.m6(..)) && args(ArrayList){}//: Should - // // runtime check (it does not match!) - // // // void around(): execution(* C.m6(..)) && args(List){}//: Should - // // match (it does) - // // // void around(): execution(* C.m6(..)) && args(ArrayList){}//: Should - // // runtime check (it does not match!) - // // // void around(): execution(* C.m6(..)) && args(ArrayList){}//: - // // Should not match (it does not match!) - // // - // // // void around(): execution(* C.m7(..)) && args(List>){} - // // //: Should not match (but it does) ERROR - // // // void around(): execution(* C.m7(..)) && - // // args(ArrayList>){}//: Should not match (but it does!) ERROR - // // // void around(): execution(* C.m7(..)) && args(List>){}//: - // // Should not match (but it does!) ERROR - // // // void around(): execution(* C.m7(..)) && - // // args(ArrayList>){}//: Should not match (but it does) ERROR - // // // void around(): execution(* C.m7(..)) && args(List>){}//: Should not match (but it does) ERROR - // // // void around(): execution(* C.m7(..)) && args(ArrayList< ? extends - // // List>){}//: Should not match (but it does!) ERROR - // // // void around(): execution(* C.m7(..)) && args(List< ? extends List>){}//: Should match (it does!) - // // // void around(): execution(* C.m7(..)) && args(ArrayList< ? extends - // // List>){}//: Should match (it does!) - // // // void around(): execution(* C.m7(..)) && args(List){}//: Should match - // // (it does) - // // // void around(): execution(* C.m7(..)) && args(ArrayList){}//: Should - // // runtime check (it does not match!) - // // // void around(): execution(* C.m7(..)) && args(List){}//: Should - // // match (it does) - // // // void around(): execution(* C.m7(..)) && args(ArrayList){}//: Should - // // runtime check (it does!) - // // // void around(): execution(* C.m7(..)) && - // // args(ArrayList>){}//: Should not match (it does not match!) - // // - // // // void around(): execution(* C.m8(..)) && args(List){} //: - // // Should match with unchecked conversion (it does) - // // // void around(): execution(* C.m8(..)) && args(ArrayList){}//: - // // Should runtime check with unchecked conversion (it does!) - // // // void around(): execution(* C.m8(..)) && args(List){}//: Should - // // match with unchecked conversion (it does!) - // // // void around(): execution(* C.m8(..)) && args(ArrayList){}//: - // // Should runtime check with unchecked conversion (it does) - // // // void around(): execution(* C.m8(..)) && args(List){}//: Should match with unchecked conversion (it does!) - // // // void around(): execution(* C.m8(..)) && args(ArrayList){}//: Should runtime check with unchecked conversion (it does) - // // // void around(): execution(* C.m8(..)) && args(List){}//: Should match - // // (it does) - // // // void around(): execution(* C.m8(..)) && args(ArrayList){}//: Should - // // runtime check (it does!) - // // // void around(): execution(* C.m8(..)) && args(List){}//: Should - // // match (it does) - // // // void around(): execution(* C.m8(..)) && args(ArrayList){}//: Should - // // runtime check (it does!) - // // // void around(): execution(* C.m8(..)) && args(ArrayList){}//: - // // Should not match (it does not match!) - // // - // // // void around(): execution(* C.m9(..)) && args(List){} //: - // // Should not match (but it does) ERROR - // // // void around(): execution(* C.m9(..)) && args(ArrayList){}//: - // // Should not match (it does not match!) - // // // void around(): execution(* C.m9(..)) && args(Number){}//: Should match - // // (it does!) - // // // void around(): execution(* C.m9(..)) && args(Integer){}//: Should - // // runtime check (it does) - // // // void around(): execution(* C.m9(..)) && args(List){}//: Should not match (but it does) ERROR - // // // void around(): execution(* C.m9(..)) && args(ArrayList){}//: Should not match (it does not match!) - // // // void around(): execution(* C.m9(..)) && args(List){}//: Should not - // // match (but it does) ERROR - // // // void around(): execution(* C.m9(..)) && args(ArrayList){}//: Should - // // not match (it does not match!) - // // // void around(): execution(* C.m9(..)) && args(List){}//: Should not - // // match (but it does) ERROR - // // // void around(): execution(* C.m9(..)) && args(ArrayList){}//: Should - // // not match (it does not match!) - // // // void around(): execution(* C.m9(..)) && args(String){}//: Should not - // // match (it does not match!) - // - // } - - private ReferenceType resolve(String sig) { - return (ReferenceType) world.resolve(UnresolvedType.forSignature(sig)); - } -} diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/TestJava5ReflectionBasedReferenceTypeDelegate.java b/weaver5/java5-testsrc/org/aspectj/weaver/TestJava5ReflectionBasedReferenceTypeDelegate.java deleted file mode 100644 index 475c330eb..000000000 --- a/weaver5/java5-testsrc/org/aspectj/weaver/TestJava5ReflectionBasedReferenceTypeDelegate.java +++ /dev/null @@ -1,154 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005-2017 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Andrew Clement Initial implementation - * ******************************************************************/ - -package org.aspectj.weaver; - -import junit.framework.Test; -import junit.framework.TestSuite; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.reflect.Field; - -import org.aspectj.weaver.reflect.ReflectionBasedReferenceTypeDelegateTest; - -public class TestJava5ReflectionBasedReferenceTypeDelegate extends ReflectionBasedReferenceTypeDelegateTest { - - public static Test suite() { - TestSuite suite = new TestSuite("TestJava5ReflectionBasedReferenceTypeDelegate"); - suite.addTestSuite(TestJava5ReflectionBasedReferenceTypeDelegate.class); - return suite; - } - - /** - * Let's play about with a generic type and ensure we can work with it in a reflective world. - */ - public void testResolveGeneric() { - UnresolvedType collectionType = UnresolvedType.forName("java.util.Collection"); - world.resolve(collectionType).getRawType().resolve(world); - ResolvedMember[] methods = world.resolve(collectionType).getDeclaredMethods(); - int i = -1; - for (int j=0;j 0); - TypeVariable tv = theGenericEnumType.getTypeVariables()[0]; - String expected = "TypeVar E extends java.lang.Enum"; - assertTrue("Type variable should be '" + expected + "' but is '" + tv + "'", tv.toString().equals(expected)); - } - - public void testResolveClass() { - world.resolve("java.lang.Class").getGenericType(); - } - - public void testGenericInterfaceSuperclass_ReflectionWorldResolution() { - - UnresolvedType javaUtilMap = UnresolvedType.forName("java.util.Map"); - - ReferenceType rawType = (ReferenceType) world.resolve(javaUtilMap); - assertTrue("Should be the raw type ?!? " + rawType.getTypekind(), rawType.isRawType()); - - ReferenceType genericType = (ReferenceType) rawType.getGenericType(); - assertTrue("Should be the generic type ?!? " + genericType.getTypekind(), genericType.isGenericType()); - - ResolvedType rt = rawType.getSuperclass(); - assertTrue("Superclass for Map raw type should be Object but was " + rt, rt.equals(UnresolvedType.OBJECT)); - - ResolvedType rt2 = genericType.getSuperclass(); - assertTrue("Superclass for Map generic type should be Object but was " + rt2, rt2.equals(UnresolvedType.OBJECT)); - } - - /** - * This is testing the optimization in the reflective annotation finder to verify that if you only want runtime - * annotation info then we use reflection and don't go digging through the classfile bytes. - */ - public void testAnnotationFinderClassRetention() throws Exception { - ResolvedType type = world.resolve(AnnoTesting.class.getName()); - ResolvedMember[] ms = type.getDeclaredMethods(); - int findMethod = findMethod("a", ms); - - ResolvedMember methodWithOnlyClassLevelAnnotation = ms[findMethod("a", ms)]; - ResolvedMember methodWithOnlyRuntimeLevelAnnotation = ms[findMethod("b", ms)]; - ResolvedMember methodWithClassAndRuntimeLevelAnnotations = ms[findMethod("c", ms)]; - ResolvedMember methodWithClassAndRuntimeLevelAnnotations2 = ms[findMethod("d", ms)]; - - assertTrue(methodWithOnlyClassLevelAnnotation.hasAnnotation(world.resolve(AnnoClass.class.getName()))); - assertTrue(methodWithOnlyRuntimeLevelAnnotation.hasAnnotation(world.resolve(AnnoRuntime.class.getName()))); - - // This is the tricky scenario. - - // When asking about the runtime level annotations it should not go digging into bcel - assertTrue(methodWithClassAndRuntimeLevelAnnotations.hasAnnotation(world.resolve(AnnoRuntime.class.getName()))); - - Field annotationsField = ResolvedMemberImpl.class.getDeclaredField("annotationTypes"); - annotationsField.setAccessible(true); - ResolvedType[] annoTypes = (ResolvedType[])annotationsField.get(methodWithClassAndRuntimeLevelAnnotations); - - // Should only be the runtime one here - assertEquals(1, annoTypes.length); - - // But when you do ask again and this time for class level, it should redo the unpack and pull both runtime and class out - assertTrue(methodWithClassAndRuntimeLevelAnnotations.hasAnnotation(world.resolve(AnnoClass.class.getName()))); - - annotationsField.setAccessible(true); - annoTypes = (ResolvedType[])annotationsField.get(methodWithClassAndRuntimeLevelAnnotations); - - // Now both should be there - assertEquals(2, annoTypes.length); - - assertTrue(methodWithClassAndRuntimeLevelAnnotations2.hasAnnotation(world.resolve(AnnoRuntime.class.getName()))); - // now ask for 'all annotations' via another route, this should reunpack and get them all - ResolvedType[] annotations = methodWithClassAndRuntimeLevelAnnotations2.getAnnotationTypes(); - assertEquals(2,annotations.length); - } - - @Retention(RetentionPolicy.CLASS) - @interface AnnoClass {} - - @Retention(RetentionPolicy.RUNTIME) - @interface AnnoRuntime {} - - class AnnoTesting { - - @AnnoClass - public void a() {} - - @AnnoRuntime - public void b() {} - - @AnnoClass @AnnoRuntime - public void c() {} - - @AnnoClass @AnnoRuntime - public void d() {} - - } - -} \ No newline at end of file diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/TypeVariableReferenceTypeTestCase.java b/weaver5/java5-testsrc/org/aspectj/weaver/TypeVariableReferenceTypeTestCase.java deleted file mode 100644 index 367a4fc93..000000000 --- a/weaver5/java5-testsrc/org/aspectj/weaver/TypeVariableReferenceTypeTestCase.java +++ /dev/null @@ -1,81 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.weaver; - -import junit.framework.TestCase; - -import org.aspectj.weaver.bcel.BcelWorld; - -/** - * @author colyer - * - */ -public class TypeVariableReferenceTypeTestCase extends TestCase { - - ReferenceType javaLangClass; - ReferenceType jlNumber; - ReferenceType javaLangObject; - BoundedReferenceType extendsClass; - BoundedReferenceType superClass; - BoundedReferenceType extendsWithExtras; - BcelWorld world; - - @Override - protected void setUp() throws Exception { - super.setUp(); - world = new BcelWorld("../bin"); - world.setBehaveInJava5Way(true); - javaLangClass = (ReferenceType) world.resolve(UnresolvedType.forName("java/lang/Class")); - jlNumber = (ReferenceType) world.resolve(UnresolvedType.forSignature("Ljava/lang/Number;")); - javaLangObject = (ReferenceType) world.resolve(UnresolvedType.OBJECT); - extendsClass = new BoundedReferenceType(javaLangClass, true, world); - superClass = new BoundedReferenceType(javaLangClass, false, world); - extendsWithExtras = new BoundedReferenceType(javaLangClass, true, world, new ReferenceType[] { (ReferenceType) world - .resolve(UnresolvedType.forName("java/util/List")) }); - } - - public void testConstructionByNameAndVariable() { - TypeVariable tv = new TypeVariable("T", javaLangClass); - TypeVariableReferenceType tvrt = new TypeVariableReferenceType(tv, world); - assertEquals("T", tvrt.getTypeVariable().getName()); - assertEquals(javaLangClass, tvrt.getTypeVariable().getUpperBound()); - } - - public void testBounds() { - // Load up the testclass from below - ResolvedType testerClass = world.resolve(Tester1.class.getName()); - ResolvedType genericTesterClass = testerClass.getGenericType(); - - // Check the declaration type variable - TypeVariable[] typevars = genericTesterClass.getTypeVariables(); - TypeVariable typevar = typevars[0]; - assertEquals(jlNumber, typevar.getUpperBound()); - assertEquals("T", typevar.getName()); - ResolvedMember member = genericTesterClass.getDeclaredMethods()[1]; - - // getParameterTypes() returning the erased parameter - UnresolvedType param = member.getParameterTypes()[0]; - assertEquals(jlNumber, param); - - // Check the type variable reference - TypeVariableReferenceType tvReference = (TypeVariableReferenceType) member.getGenericParameterTypes()[0]; - assertEquals("T", tvReference.getTypeVariableName()); - assertEquals(jlNumber, tvReference.getUpperBound()); - assertEquals(jlNumber, tvReference.getDelegate().getResolvedTypeX()); - } - - class Tester1 { - public void method(T t) { - } - } - -} diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/TypeVariableTestCase.java b/weaver5/java5-testsrc/org/aspectj/weaver/TypeVariableTestCase.java deleted file mode 100644 index 8ef8f70c1..000000000 --- a/weaver5/java5-testsrc/org/aspectj/weaver/TypeVariableTestCase.java +++ /dev/null @@ -1,110 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.weaver; - -import junit.framework.TestCase; - -import org.aspectj.weaver.bcel.BcelWorld; - -public class TypeVariableTestCase extends TestCase { - - private UnresolvedType javaLangNumber; - private UnresolvedType javaLangDouble; - private UnresolvedType javaUtilList; - private UnresolvedType javaIoSerializable; - private World world; - - public void testName() { - TypeVariable tv = new TypeVariable("T"); - assertEquals("T", tv.getName()); - } - - public void testDefaultBounds() { - TypeVariable tv = new TypeVariable("T"); - assertEquals("Object", UnresolvedType.OBJECT, tv.getFirstBound()); - assertNull(tv.getUpperBound()); - assertEquals("no additional bounds", 0, tv.getSuperInterfaces().length); - } - - public void testUpperBound() { - TypeVariable tv = new TypeVariable("N", javaLangNumber); - assertEquals("java.lang.Number", javaLangNumber, tv.getUpperBound()); - } - - public void testAdditionalUpperBounds() { - TypeVariable tv = new TypeVariable("E", UnresolvedType.OBJECT, new UnresolvedType[] { javaUtilList }); - assertEquals("1 additional bound", 1, tv.getSuperInterfaces().length); - assertEquals("java.util.List", javaUtilList, tv.getSuperInterfaces()[0]); - - tv = new TypeVariable("E", null, new UnresolvedType[] { javaUtilList }); - assertEquals("1 additional bound", 1, tv.getSuperInterfaces().length); - assertEquals("java.util.List", javaUtilList, tv.getSuperInterfaces()[0]); - } - - public void testResolution() { - TypeVariable tv = new TypeVariable("T", javaLangNumber, new UnresolvedType[] { javaUtilList }); - tv.resolve(world); - assertEquals("resolved number", javaLangNumber.resolve(world), tv.getUpperBound()); - assertEquals("resolved list", javaUtilList.resolve(world), tv.getSuperInterfaces()[0]); - } - - public void testBindWithoutResolve() { - TypeVariable tv = new TypeVariable("X"); - try { - tv.canBeBoundTo(null); - fail("Should throw illegal state exception"); - } catch (IllegalStateException ex) { - } - } - - public void testCanBindToUpperMatch() { - TypeVariable tv = new TypeVariable("X", javaLangNumber); - tv.resolve(world); - assertTrue(tv.canBeBoundTo(javaLangDouble.resolve(world))); - } - - public void testCanBindToUpperFail() { - TypeVariable tv = new TypeVariable("X", javaLangNumber); - tv.resolve(world); - assertFalse(tv.canBeBoundTo(UnresolvedType.OBJECT.resolve(world))); - } - - public void testCanBindToInterfaceMatch() { - TypeVariable tv = new TypeVariable("T", javaLangNumber, new UnresolvedType[] { javaIoSerializable }); - tv.resolve(world); - assertTrue(tv.canBeBoundTo(javaLangDouble.resolve(world))); - } - - public void testCanBindToInterfaceFail() { - TypeVariable tv = new TypeVariable("T", javaLangNumber, new UnresolvedType[] { javaUtilList }); - tv.resolve(world); - assertFalse(tv.canBeBoundTo(javaLangDouble.resolve(world))); - } - - // --- - - @Override - protected void setUp() throws Exception { - super.setUp(); - javaLangNumber = UnresolvedType.forSignature("Ljava/lang/Number;"); - javaLangDouble = UnresolvedType.forSignature("Ljava/lang/Double;"); - javaIoSerializable = UnresolvedType.forSignature("Ljava/io/Serializable;"); - javaUtilList = UnresolvedType.forSignature("Ljava/util/List;"); - world = new BcelWorld(); - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - } - -} diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/bcel/BcelGenericSignatureToTypeXTestCase.java b/weaver5/java5-testsrc/org/aspectj/weaver/bcel/BcelGenericSignatureToTypeXTestCase.java deleted file mode 100644 index 58f774840..000000000 --- a/weaver5/java5-testsrc/org/aspectj/weaver/bcel/BcelGenericSignatureToTypeXTestCase.java +++ /dev/null @@ -1,68 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.weaver.bcel; - -import junit.framework.TestCase; - -import org.aspectj.apache.bcel.Repository; -import org.aspectj.apache.bcel.classfile.JavaClass; -import org.aspectj.apache.bcel.classfile.Signature; -import org.aspectj.util.GenericSignature; -import org.aspectj.util.GenericSignatureParser; -import org.aspectj.util.GenericSignature.ClassSignature; -import org.aspectj.weaver.UnresolvedType; - -/** - * @author colyer - * - */ -public class BcelGenericSignatureToTypeXTestCase extends TestCase { - - public final GenericSignature.ClassSignature getGenericClassTypeSignature(JavaClass jClass) { - Signature sig = jClass.getSignatureAttribute(); - if (sig != null) { - GenericSignatureParser parser = new GenericSignatureParser(); - ClassSignature classSig = parser.parseAsClassSignature(sig.getSignature()); - return classSig; - } - return null; - } - - public void testEnumFromHell() throws Exception { - BcelWorld world = new BcelWorld(); - JavaClass javaLangEnum = Repository.lookupClass("java/lang/Enum"); - GenericSignature.ClassSignature cSig = getGenericClassTypeSignature(javaLangEnum); - UnresolvedType superclass = BcelGenericSignatureToTypeXConverter.classTypeSignature2TypeX(cSig.superclassSignature, - cSig.formalTypeParameters, world); - assertEquals("Ljava/lang/Object;", superclass.getSignature()); - assertEquals("2 superinterfaces", 2, cSig.superInterfaceSignatures.length); - UnresolvedType comparable = BcelGenericSignatureToTypeXConverter.classTypeSignature2TypeX(cSig.superInterfaceSignatures[0], - cSig.formalTypeParameters, world); - assertEquals("Pjava/lang/Comparable;", comparable.getSignature()); - UnresolvedType serializable = BcelGenericSignatureToTypeXConverter.classTypeSignature2TypeX( - cSig.superInterfaceSignatures[1], cSig.formalTypeParameters, world); - assertEquals("Ljava/io/Serializable;", serializable.getSignature()); - } - - public void testColonColon() throws Exception { - BcelWorld world = new BcelWorld(); - GenericSignature.ClassSignature cSig = new GenericSignatureParser() - .parseAsClassSignature("Ljava/lang/Object;Ljava/lang/Comparable;"); - UnresolvedType resolved = BcelGenericSignatureToTypeXConverter.classTypeSignature2TypeX(cSig.superclassSignature, - cSig.formalTypeParameters, world); - assertEquals("Ljava/lang/Object;", resolved.getSignature()); - BcelGenericSignatureToTypeXConverter.classTypeSignature2TypeX(cSig.superInterfaceSignatures[0], cSig.formalTypeParameters, - world); - - } - -} diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/bcel/BcelWorldReferenceTypeTest.java b/weaver5/java5-testsrc/org/aspectj/weaver/bcel/BcelWorldReferenceTypeTest.java deleted file mode 100644 index 0ab70023e..000000000 --- a/weaver5/java5-testsrc/org/aspectj/weaver/bcel/BcelWorldReferenceTypeTest.java +++ /dev/null @@ -1,23 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2002-2008 Contributors - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * PARC initial implementation - * ******************************************************************/ -package org.aspectj.weaver.bcel; - -import org.aspectj.weaver.CommonReferenceTypeTests; -import org.aspectj.weaver.World; - -public class BcelWorldReferenceTypeTest extends CommonReferenceTypeTests { - - public World getWorld() { - return new BcelWorld(); - } - -} diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/patterns/WildTypePatternResolutionTestCase.java b/weaver5/java5-testsrc/org/aspectj/weaver/patterns/WildTypePatternResolutionTestCase.java deleted file mode 100644 index 5eda5d577..000000000 --- a/weaver5/java5-testsrc/org/aspectj/weaver/patterns/WildTypePatternResolutionTestCase.java +++ /dev/null @@ -1,422 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer initial implementation - * ******************************************************************/ -package org.aspectj.weaver.patterns; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; - -import junit.framework.TestCase; - -import org.aspectj.weaver.BoundedReferenceType; -import org.aspectj.weaver.CompressingDataOutputStream; -import org.aspectj.weaver.ResolvedType; -import org.aspectj.weaver.TypeFactory; -import org.aspectj.weaver.UnresolvedType; -import org.aspectj.weaver.VersionedDataInputStream; -import org.aspectj.weaver.World; -import org.aspectj.weaver.AjAttribute.WeaverVersionInfo; -import org.aspectj.weaver.bcel.BcelWorld; - -// TODO write test cases for instanceof matching - -public class WildTypePatternResolutionTestCase extends TestCase { - - private World world; - private Bindings bindings; - private SimpleScope scope; - private ResolvedType javaUtilList; - private ResolvedType javaLangString; - private ResolvedType javaUtilListOfString; - private ResolvedType javaUtilListOfDouble; - private ResolvedType javaUtilListOfSomething; - - /** - * Foo where Foo exists and is generic Parser creates WildTypePattern namePatterns={Foo} resolveBindings resolves Foo to RT(Foo - * - raw) return ExactTypePattern(LFoo;) - */ - public void testSimpleFoo() { - TypePattern rtp = resolveWildTypePattern("List", false); - - assertTrue("resolves to exact type", rtp instanceof ExactTypePattern); - UnresolvedType exactType = rtp.getExactType(); - assertTrue(exactType.isRawType()); - assertEquals("Ljava/util/List;", exactType.getSignature()); - - ResolvedType rt = exactType.resolve(world); - assertEquals("Ljava/util/List;", rt.getSignature()); - assertTrue(rt.isRawType()); - - ExactTypePattern etp = (ExactTypePattern) writeAndRead(rtp); - exactType = etp.getExactType(); - - assertEquals("Ljava/util/List;", exactType.getSignature()); - - rt = exactType.resolve(world); - assertEquals("Ljava/util/List;", rt.getSignature()); - assertTrue(rt.isRawType()); - - assertTrue("matches List", etp.matches(javaUtilList, TypePattern.STATIC).alwaysTrue()); - assertTrue("matches generic List", etp.matches(javaUtilList.getGenericType(), TypePattern.STATIC).alwaysTrue()); - assertTrue("matches parameterized list", etp.matches(javaUtilListOfString, TypePattern.STATIC).alwaysTrue()); - assertTrue("does not match String", etp.matches(javaLangString, TypePattern.STATIC).alwaysFalse()); - } - - /** - * Foo where Foo exists and String meets the bounds Parser creates WildTypePattern namePatterns = {Foo}, - * typeParameters=WTP{String} resolveBindings resolves typeParameters to ExactTypePattern(String) resolves Foo to RT(Foo) - * returns ExactTypePattern(PFoo; - parameterized) - */ - public void testParameterized() { - TypePattern rtp = resolveWildTypePattern("List", false); - - assertTrue("resolves to exact type", rtp instanceof ExactTypePattern); - UnresolvedType exactType = rtp.getExactType(); - assertTrue(exactType.isParameterizedType()); - assertEquals("Pjava/util/List;", exactType.getSignature()); - - ResolvedType rt = exactType.resolve(world); - assertEquals("Pjava/util/List;", rt.getSignature()); - assertTrue(rt.isParameterizedType()); - - ExactTypePattern etp = (ExactTypePattern) writeAndRead(rtp); - exactType = etp.getExactType(); - - assertEquals("Pjava/util/List;", rt.getSignature()); - assertTrue(rt.isParameterizedType()); - - rt = exactType.resolve(world); - assertEquals("Pjava/util/List;", rt.getSignature()); - assertTrue(rt.isParameterizedType()); - - assertFalse("does not match List", etp.matches(javaUtilList, TypePattern.STATIC).alwaysTrue()); - assertFalse("does not match generic List", etp.matches(javaUtilList.getGenericType(), TypePattern.STATIC).alwaysTrue()); - assertTrue("matches parameterized list", etp.matches(javaUtilListOfString, TypePattern.STATIC).alwaysTrue()); - assertFalse("does not match parameterized list of double", etp.matches(javaUtilListOfDouble, TypePattern.STATIC) - .alwaysTrue()); - assertTrue("does not match String", etp.matches(javaLangString, TypePattern.STATIC).alwaysFalse()); - - } - - /** - * Foo where Foo exists and takes one bound Parser creates WildTypePattern namePatterns = {Foo}, typeParameters=WTP{Str*} - * resolveBindings resolves typeParameters to WTP{Str*} resolves Foo to RT(Foo) returns WildTypePattern(name = Foo, - * typeParameters = WTP{Str*} isGeneric=false) - */ - public void testParameterizedWildCard() { - TypePattern rtp = resolveWildTypePattern("List", false); - - assertTrue("resolves to WildTypePattern", rtp instanceof WildTypePattern); - assertTrue("one type parameter", rtp.typeParameters.size() == 1); - assertTrue("missing", ResolvedType.isMissing(rtp.getExactType())); - - WildTypePattern wtp = (WildTypePattern) writeAndRead(rtp); - assertTrue("one type parameter", wtp.typeParameters.size() == 1); - assertTrue("missing", ResolvedType.isMissing(wtp.getExactType())); - assertEquals("Str*", wtp.getTypeParameters().getTypePatterns()[0].toString()); - - assertFalse("does not match List", wtp.matches(javaUtilList, TypePattern.STATIC).alwaysTrue()); - assertFalse("does not match generic List", wtp.matches(javaUtilList.getGenericType(), TypePattern.STATIC).alwaysTrue()); - assertTrue("matches parameterized list", wtp.matches(javaUtilListOfString, TypePattern.STATIC).alwaysTrue()); - assertFalse("does not match parameterized list of double", wtp.matches(javaUtilListOfDouble, TypePattern.STATIC) - .alwaysTrue()); - assertTrue("does not match String", wtp.matches(javaLangString, TypePattern.STATIC).alwaysFalse()); - } - - /** - * Fo* Parser creates WildTypePattern namePatterns = {Fo*}, typeParameters=WTP{String} resolveBindings resolves - * typeParameters to ETP{String} returns WildTypePattern(name = Fo*, typeParameters = ETP{String} isGeneric=false) - */ - public void testWildcardParameterized() { - TypePattern rtp = resolveWildTypePattern("Li*", false); - - assertTrue("resolves to WildTypePattern", rtp instanceof WildTypePattern); - assertTrue("one type parameter", rtp.typeParameters.size() == 1); - assertEquals("Ljava/lang/String;", rtp.typeParameters.getTypePatterns()[0].getExactType().getSignature()); - - WildTypePattern wtp = (WildTypePattern) writeAndRead(rtp); - assertTrue("one type parameter", wtp.typeParameters.size() == 1); - assertEquals("Ljava/lang/String;", wtp.typeParameters.getTypePatterns()[0].getExactType().getSignature()); - - assertFalse("does not match List", wtp.matches(javaUtilList, TypePattern.STATIC).alwaysTrue()); - assertFalse("does not match generic List", wtp.matches(javaUtilList.getGenericType(), TypePattern.STATIC).alwaysTrue()); - assertTrue("matches parameterized list", wtp.matches(javaUtilListOfString, TypePattern.STATIC).alwaysTrue()); - assertFalse("does not match parameterized list of double", wtp.matches(javaUtilListOfDouble, TypePattern.STATIC) - .alwaysTrue()); - assertTrue("does not match String", wtp.matches(javaLangString, TypePattern.STATIC).alwaysFalse()); - } - - /** - * Foo - */ - public void testSomething() { - TypePattern rtp = resolveWildTypePattern("List", false); - - assertTrue("resolves to exact type", rtp instanceof ExactTypePattern); - UnresolvedType exactType = rtp.getExactType(); - assertTrue(exactType.isParameterizedType()); - assertEquals("Pjava/util/List<*>;", exactType.getSignature()); - - ExactTypePattern etp = (ExactTypePattern) writeAndRead(rtp); - exactType = etp.getExactType(); - assertTrue(exactType.isParameterizedType()); - assertEquals("Pjava/util/List<*>;", exactType.getSignature()); - - assertFalse("does not match List", etp.matches(javaUtilList, TypePattern.STATIC).alwaysTrue()); - assertFalse("does not match generic List", etp.matches(javaUtilList.getGenericType(), TypePattern.STATIC).alwaysTrue()); - assertFalse("does not match parameterized list", etp.matches(javaUtilListOfString, TypePattern.STATIC).alwaysTrue()); - assertFalse("does not match parameterized list of double", etp.matches(javaUtilListOfDouble, TypePattern.STATIC) - .alwaysTrue()); - assertTrue("does not match String", etp.matches(javaLangString, TypePattern.STATIC).alwaysFalse()); - - assertTrue("matches list of something", etp.matches(javaUtilListOfSomething, TypePattern.STATIC).alwaysTrue()); - } - - /** - * Foo - */ - public void testSomethingExtends() { - TypePattern rtp = resolveWildTypePattern("List", false); - - assertTrue("resolves to exact type", rtp instanceof ExactTypePattern); - UnresolvedType exactType = rtp.getExactType(); - assertTrue(exactType.isParameterizedType()); - assertEquals("Pjava/util/List<+Ljava/lang/Number;>;", exactType.getSignature()); - assertTrue("got a bounded reference type", exactType.getTypeParameters()[0] instanceof BoundedReferenceType); - - ExactTypePattern etp = (ExactTypePattern) writeAndRead(rtp); - exactType = etp.getExactType(); - exactType = exactType.resolve(world); - assertTrue(exactType.isParameterizedType()); - assertEquals("Pjava/util/List<+Ljava/lang/Number;>;", exactType.getSignature()); - assertTrue("got a bounded reference type", exactType.getTypeParameters()[0] instanceof BoundedReferenceType); - - assertFalse("does not match List", etp.matches(javaUtilList, TypePattern.STATIC).alwaysTrue()); - assertFalse("does not match generic List", etp.matches(javaUtilList.getGenericType(), TypePattern.STATIC).alwaysTrue()); - assertFalse("does not match parameterized list", etp.matches(javaUtilListOfString, TypePattern.STATIC).alwaysTrue()); - assertFalse("does not match parameterized list of double", etp.matches(javaUtilListOfDouble, TypePattern.STATIC) - .alwaysTrue()); - assertTrue("does not match String", etp.matches(javaLangString, TypePattern.STATIC).alwaysFalse()); - assertFalse("does not match list of something", etp.matches(javaUtilListOfSomething, TypePattern.STATIC).alwaysTrue()); - - ResolvedType listOfNumber = TypeFactory.createParameterizedType(javaUtilList, new UnresolvedType[] { UnresolvedType - .forName("java.lang.Number").resolve(world) }, world); - - ResolvedType listOfDouble = TypeFactory.createParameterizedType(javaUtilList, new UnresolvedType[] { UnresolvedType - .forName("java.lang.Double").resolve(world) }, world); - - assertFalse("does not match list of number", etp.matches(listOfNumber, TypePattern.STATIC).alwaysTrue()); - assertFalse("does not match list of double", etp.matches(listOfDouble, TypePattern.STATIC).alwaysTrue()); - - ResolvedType extendsNumber = TypeFactory.createTypeFromSignature("+Ljava/lang/Number;").resolve(world); - ResolvedType listOfExtendsNumber = TypeFactory.createParameterizedType(javaUtilList, - new UnresolvedType[] { extendsNumber }, world); - - assertTrue("matches list of ? extends number", etp.matches(listOfExtendsNumber, TypePattern.STATIC).alwaysTrue()); - - } - - /** - * Foo - */ - public void testSomethingExtendsPattern() { - TypePattern rtp = resolveWildTypePattern("List", false); - - assertTrue("resolves to wild type pattern", rtp instanceof WildTypePattern); - assertEquals("one type parameter", 1, rtp.getTypeParameters().size()); - TypePattern tp = rtp.getTypeParameters().getTypePatterns()[0]; - assertTrue("parameter is wild", tp instanceof WildTypePattern); - WildTypePattern tpwtp = (WildTypePattern) tp; - assertEquals("?", tpwtp.getNamePatterns()[0].maybeGetSimpleName()); - assertEquals("java.lang.Number+", tpwtp.upperBound.toString()); - - WildTypePattern wtp = (WildTypePattern) writeAndRead(rtp); - assertEquals("one type parameter", 1, wtp.getTypeParameters().size()); - tp = rtp.getTypeParameters().getTypePatterns()[0]; - assertTrue("parameter is wild", tp instanceof WildTypePattern); - tpwtp = (WildTypePattern) tp; - assertEquals("?", tpwtp.getNamePatterns()[0].maybeGetSimpleName()); - assertEquals("java.lang.Number+", tpwtp.upperBound.toString()); - - assertFalse("does not match List", wtp.matches(javaUtilList, TypePattern.STATIC).alwaysTrue()); - assertFalse("does not match generic List", wtp.matches(javaUtilList.getGenericType(), TypePattern.STATIC).alwaysTrue()); - assertFalse("does not match parameterized list", wtp.matches(javaUtilListOfString, TypePattern.STATIC).alwaysTrue()); - assertFalse("does not match parameterized list of double", wtp.matches(javaUtilListOfDouble, TypePattern.STATIC) - .alwaysTrue()); - assertTrue("does not match String", wtp.matches(javaLangString, TypePattern.STATIC).alwaysFalse()); - assertFalse("does not match list of something", wtp.matches(javaUtilListOfSomething, TypePattern.STATIC).alwaysTrue()); - - ResolvedType listOfNumber = TypeFactory.createParameterizedType(javaUtilList, new UnresolvedType[] { UnresolvedType - .forName("java.lang.Number").resolve(world) }, world); - - ResolvedType listOfDouble = TypeFactory.createParameterizedType(javaUtilList, new UnresolvedType[] { UnresolvedType - .forName("java.lang.Double").resolve(world) }, world); - - assertFalse("does not match list of number", wtp.matches(listOfNumber, TypePattern.STATIC).alwaysTrue()); - assertFalse("does not match list of double", wtp.matches(listOfDouble, TypePattern.STATIC).alwaysTrue()); - - ResolvedType extendsNumber = TypeFactory.createTypeFromSignature("+Ljava/lang/Number;").resolve(world); - ResolvedType listOfExtendsNumber = TypeFactory.createParameterizedType(javaUtilList, - new UnresolvedType[] { extendsNumber }, world); - - assertTrue("matches list of ? extends number", wtp.matches(listOfExtendsNumber, TypePattern.STATIC).alwaysTrue()); - - ResolvedType extendsDouble = TypeFactory.createTypeFromSignature("+Ljava/lang/Double;").resolve(world); - ResolvedType listOfExtendsDouble = TypeFactory.createParameterizedType(javaUtilList, - new UnresolvedType[] { extendsDouble }, world); - - assertTrue("matches list of ? extends double", wtp.matches(listOfExtendsDouble, TypePattern.STATIC).alwaysTrue()); - - } - - /** - * Foo - */ - public void testSomethingExtendsPatternv2() { - TypePattern rtp = resolveWildTypePattern("List", false); - - assertTrue("resolves to wild type pattern", rtp instanceof WildTypePattern); - assertEquals("one type parameter", 1, rtp.getTypeParameters().size()); - TypePattern tp = rtp.getTypeParameters().getTypePatterns()[0]; - assertTrue("parameter is wild", tp instanceof WildTypePattern); - WildTypePattern tpwtp = (WildTypePattern) tp; - assertEquals("?", tpwtp.getNamePatterns()[0].maybeGetSimpleName()); - assertEquals("Num*", tpwtp.upperBound.toString()); - - WildTypePattern wtp = (WildTypePattern) writeAndRead(rtp); - assertEquals("one type parameter", 1, wtp.getTypeParameters().size()); - tp = rtp.getTypeParameters().getTypePatterns()[0]; - assertTrue("parameter is wild", tp instanceof WildTypePattern); - tpwtp = (WildTypePattern) tp; - assertEquals("?", tpwtp.getNamePatterns()[0].maybeGetSimpleName()); - assertEquals("Num*", tpwtp.upperBound.toString()); - - assertFalse("does not match List", wtp.matches(javaUtilList, TypePattern.STATIC).alwaysTrue()); - assertFalse("does not match generic List", wtp.matches(javaUtilList.getGenericType(), TypePattern.STATIC).alwaysTrue()); - assertFalse("does not match parameterized list", wtp.matches(javaUtilListOfString, TypePattern.STATIC).alwaysTrue()); - assertFalse("does not match parameterized list of double", wtp.matches(javaUtilListOfDouble, TypePattern.STATIC) - .alwaysTrue()); - assertTrue("does not match String", wtp.matches(javaLangString, TypePattern.STATIC).alwaysFalse()); - assertFalse("does not match list of something", wtp.matches(javaUtilListOfSomething, TypePattern.STATIC).alwaysTrue()); - - ResolvedType listOfNumber = TypeFactory.createParameterizedType(javaUtilList, new UnresolvedType[] { UnresolvedType - .forName("java.lang.Number").resolve(world) }, world); - - ResolvedType listOfDouble = TypeFactory.createParameterizedType(javaUtilList, new UnresolvedType[] { UnresolvedType - .forName("java.lang.Double").resolve(world) }, world); - - assertFalse("does not match list of number", wtp.matches(listOfNumber, TypePattern.STATIC).alwaysTrue()); - assertFalse("does not match list of double", wtp.matches(listOfDouble, TypePattern.STATIC).alwaysTrue()); - - ResolvedType extendsNumber = TypeFactory.createTypeFromSignature("+Ljava/lang/Number;").resolve(world); - ResolvedType listOfExtendsNumber = TypeFactory.createParameterizedType(javaUtilList, - new UnresolvedType[] { extendsNumber }, world); - - assertTrue("matches list of ? extends number", wtp.matches(listOfExtendsNumber, TypePattern.STATIC).alwaysTrue()); - - ResolvedType extendsDouble = TypeFactory.createTypeFromSignature("+Ljava/lang/Double;").resolve(world); - ResolvedType listOfExtendsDouble = TypeFactory.createParameterizedType(javaUtilList, - new UnresolvedType[] { extendsDouble }, world); - - assertFalse("does not match list of ? extends double", wtp.matches(listOfExtendsDouble, TypePattern.STATIC).alwaysTrue()); - } - - /** - * Foo - * - */ - public void testSomethingSuper() { - TypePattern rtp = resolveWildTypePattern("List", false); - - assertTrue("resolves to exact type", rtp instanceof ExactTypePattern); - UnresolvedType exactType = rtp.getExactType(); - assertTrue(exactType.isParameterizedType()); - assertEquals("Pjava/util/List<-Ljava/lang/Double;>;", exactType.getSignature()); - assertTrue("got a bounded reference type", exactType.getTypeParameters()[0] instanceof BoundedReferenceType); - - ExactTypePattern etp = (ExactTypePattern) writeAndRead(rtp); - exactType = etp.getExactType(); - exactType = exactType.resolve(world); - assertTrue(exactType.isParameterizedType()); - assertEquals("Pjava/util/List<-Ljava/lang/Double;>;", exactType.getSignature()); - assertTrue("got a bounded reference type", exactType.getTypeParameters()[0] instanceof BoundedReferenceType); - - assertFalse("does not match List", etp.matches(javaUtilList, TypePattern.STATIC).alwaysTrue()); - assertFalse("does not match generic List", etp.matches(javaUtilList.getGenericType(), TypePattern.STATIC).alwaysTrue()); - assertFalse("does not match parameterized list", etp.matches(javaUtilListOfString, TypePattern.STATIC).alwaysTrue()); - assertFalse("does not match parameterized list of double", etp.matches(javaUtilListOfDouble, TypePattern.STATIC) - .alwaysTrue()); - assertTrue("does not match String", etp.matches(javaLangString, TypePattern.STATIC).alwaysFalse()); - assertFalse("does not match list of something", etp.matches(javaUtilListOfSomething, TypePattern.STATIC).alwaysTrue()); - - ResolvedType listOfNumber = TypeFactory.createParameterizedType(javaUtilList, new UnresolvedType[] { UnresolvedType - .forName("java.lang.Number").resolve(world) }, world); - - ResolvedType listOfDouble = TypeFactory.createParameterizedType(javaUtilList, new UnresolvedType[] { UnresolvedType - .forName("java.lang.Double").resolve(world) }, world); - - assertFalse("does not match list of number", etp.matches(listOfNumber, TypePattern.STATIC).alwaysTrue()); - assertFalse("does not match list of double", etp.matches(listOfDouble, TypePattern.STATIC).alwaysTrue()); - - ResolvedType superDouble = TypeFactory.createTypeFromSignature("-Ljava/lang/Double;").resolve(world); - ResolvedType listOfSuperDouble = TypeFactory.createParameterizedType(javaUtilList, new UnresolvedType[] { superDouble }, - world); - - assertTrue("matches list of ? super double", etp.matches(listOfSuperDouble, TypePattern.STATIC).alwaysTrue()); - } - - private TypePattern resolveWildTypePattern(String source, boolean requireExact) { - WildTypePattern wtp = makeWildTypePattern(source); - return wtp.resolveBindings(scope, bindings, false, requireExact); - } - - private WildTypePattern makeWildTypePattern(String source) { - PatternParser parser = new PatternParser(source); - return (WildTypePattern) parser.parseTypePattern(); - } - - private TypePattern writeAndRead(TypePattern etp) { - try { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ConstantPoolSimulator cps = new ConstantPoolSimulator(); - CompressingDataOutputStream dos = new CompressingDataOutputStream(baos, cps); - etp.write(dos); - dos.flush(); - dos.close(); - ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); - VersionedDataInputStream in = new VersionedDataInputStream(bais, cps); - in.setVersion(new WeaverVersionInfo()); - TypePattern ret = TypePattern.read(in, null); - return ret; - } catch (IOException ioEx) { - fail(ioEx + " thrown during serialization"); - } - return null; - } - - protected void setUp() throws Exception { - super.setUp(); - this.world = new BcelWorld(); - this.world.setBehaveInJava5Way(true); - this.bindings = new Bindings(0); - this.scope = new SimpleScope(world, new FormalBinding[] {}); - this.scope.setImportedPrefixes(new String[] { "java.io.", "java.util.", "java.lang." }); - this.javaLangString = UnresolvedType.forName("java.lang.String").resolve(world); - this.javaUtilList = UnresolvedType.forName("java.util.List").resolve(world); - this.javaUtilListOfString = TypeFactory.createParameterizedType(javaUtilList, new UnresolvedType[] { javaLangString }, - world); - this.javaUtilListOfDouble = TypeFactory.createParameterizedType(javaUtilList, new UnresolvedType[] { UnresolvedType - .forName("java.lang.Double").resolve(world) }, world); - this.javaUtilListOfSomething = TypeFactory.createParameterizedType(javaUtilList, - new UnresolvedType[] { UnresolvedType.SOMETHING.resolve(world) }, world); - } -} diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateTest.java b/weaver5/java5-testsrc/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateTest.java deleted file mode 100644 index 72c7c85f7..000000000 --- a/weaver5/java5-testsrc/org/aspectj/weaver/reflect/ReflectionBasedReferenceTypeDelegateTest.java +++ /dev/null @@ -1,316 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.weaver.reflect; - -import java.lang.reflect.Method; -import java.util.HashSet; -import java.util.Set; - -import junit.framework.TestCase; - -import org.aspectj.bridge.IMessageHandler; -import org.aspectj.weaver.ReferenceType; -import org.aspectj.weaver.ResolvedMember; -import org.aspectj.weaver.ResolvedType; -import org.aspectj.weaver.UnresolvedType; -import org.aspectj.weaver.bcel.BcelWorld; - -public abstract class ReflectionBasedReferenceTypeDelegateTest extends TestCase { - - protected ReflectionWorld world; - private ResolvedType objectType; - private ResolvedType classType; - - public void testIsAspect() { - assertFalse(objectType.isAspect()); - } - - public void testIsAnnotationStyleAspect() { - assertFalse(objectType.isAnnotationStyleAspect()); - } - - public void testIsInterface() { - assertFalse(objectType.isInterface()); - assertTrue(world.resolve("java.io.Serializable").isInterface()); - } - - public void testIsEnum() { - assertFalse(objectType.isEnum()); - } - - public void testIsAnnotation() { - assertFalse(objectType.isAnnotation()); - } - - public void testIsAnnotationWithRuntimeRetention() { - assertFalse(objectType.isAnnotationWithRuntimeRetention()); - } - - public void testIsClass() { - assertTrue(objectType.isClass()); - assertFalse(world.resolve("java.io.Serializable").isClass()); - } - - public void testIsGeneric() { - assertFalse(objectType.isGenericType()); - } - - public void testIsExposedToWeaver() { - assertFalse(objectType.isExposedToWeaver()); - } - - public void testHasAnnotation() { - assertFalse(objectType.hasAnnotation(UnresolvedType.forName("Foo"))); - } - - public void testGetAnnotations() { - assertEquals("no entries", 0, objectType.getAnnotations().length); - } - - public void testGetAnnotationTypes() { - assertEquals("no entries", 0, objectType.getAnnotationTypes().length); - } - - public void testGetTypeVariables() { - assertEquals("no entries", 0, objectType.getTypeVariables().length); - } - - public void testGetPerClause() { - assertNull(objectType.getPerClause()); - } - - public void testGetModifiers() { - assertEquals(Object.class.getModifiers(), objectType.getModifiers()); - } - - public void testGetSuperclass() { - assertTrue("Superclass of object should be null, but it is: " + objectType.getSuperclass(), - objectType.getSuperclass() == null); - assertEquals(objectType, world.resolve("java.lang.Class").getSuperclass()); - ResolvedType d = world.resolve("reflect.tests.D"); - assertEquals(world.resolve("reflect.tests.C"), d.getSuperclass()); - } - - protected int findMethod(String name, ResolvedMember[] methods) { - for (int i = 0; i < methods.length; i++) { - if (name.equals(methods[i].getName())) { - return i; - } - } - return -1; - } - - protected int findMethod(String name, int numArgs, ResolvedMember[] methods) { - for (int i = 0; i < methods.length; i++) { - if (name.equals(methods[i].getName()) && (methods[i].getParameterTypes().length == numArgs)) { - return i; - } - } - return -1; - } - - public void testGetDeclaredMethods() { - ResolvedMember[] methods = objectType.getDeclaredMethods(); - assertEquals(Object.class.getDeclaredMethods().length + Object.class.getDeclaredConstructors().length, methods.length); - - ResolvedType c = world.resolve("reflect.tests.C"); - methods = c.getDeclaredMethods(); - assertEquals(3, methods.length); - int idx = findMethod("foo", methods); - assertTrue(idx > -1); - - assertEquals(world.resolve("java.lang.String"), methods[idx].getReturnType()); - assertEquals(1, methods[idx].getParameterTypes().length); - assertEquals(objectType, methods[idx].getParameterTypes()[0]); - assertEquals(1, methods[idx].getExceptions().length); - assertEquals(world.resolve("java.lang.Exception"), methods[idx].getExceptions()[0]); - int baridx = findMethod("bar", methods); - int initidx = findMethod("", methods); - assertTrue(baridx > -1); - assertTrue(initidx > -1); - assertTrue(baridx != initidx && baridx != idx && idx <= 2 && initidx <= 2 && baridx <= 2); - - ResolvedType d = world.resolve("reflect.tests.D"); - methods = d.getDeclaredMethods(); - assertEquals(2, methods.length); - - classType = world.resolve("java.lang.Class"); - methods = classType.getDeclaredMethods(); - assertEquals(Class.class.getDeclaredMethods().length + Class.class.getDeclaredConstructors().length, methods.length); - } - - public void testGetDeclaredFields() { - ResolvedMember[] fields = objectType.getDeclaredFields(); - assertEquals(0, fields.length); - - ResolvedType c = world.resolve("reflect.tests.C"); - fields = c.getDeclaredFields(); - - assertEquals(2, fields.length); - assertEquals("f", fields[0].getName()); - assertEquals("s", fields[1].getName()); - assertEquals(UnresolvedType.INT, fields[0].getReturnType()); - assertEquals(world.resolve("java.lang.String"), fields[1].getReturnType()); - } - - public void testGetDeclaredInterfaces() { - ResolvedType[] interfaces = objectType.getDeclaredInterfaces(); - assertEquals(0, interfaces.length); - - ResolvedType d = world.resolve("reflect.tests.D"); - interfaces = d.getDeclaredInterfaces(); - assertEquals(1, interfaces.length); - assertEquals(world.resolve("java.io.Serializable"), interfaces[0]); - } - - public void testGetDeclaredPointcuts() { - ResolvedMember[] pointcuts = objectType.getDeclaredPointcuts(); - assertEquals(0, pointcuts.length); - } - - public void testSerializableSuperclass() { - ResolvedType serializableType = world.resolve("java.io.Serializable"); - ResolvedType superType = serializableType.getSuperclass(); - assertTrue("Superclass of serializable should be Object but was " + superType, superType.equals(UnresolvedType.OBJECT)); - - BcelWorld bcelworld = new BcelWorld(); - bcelworld.setBehaveInJava5Way(true); - ResolvedType bcelSupertype = bcelworld.resolve(UnresolvedType.SERIALIZABLE).getSuperclass(); - assertTrue("Should be null but is " + bcelSupertype, bcelSupertype.equals(UnresolvedType.OBJECT)); - } - - public void testSubinterfaceSuperclass() { - ResolvedType ifaceType = world.resolve("java.security.Key"); - ResolvedType superType = ifaceType.getSuperclass(); - assertTrue("Superclass should be Object but was " + superType, superType.equals(UnresolvedType.OBJECT)); - - BcelWorld bcelworld = new BcelWorld(); - bcelworld.setBehaveInJava5Way(true); - ResolvedType bcelSupertype = bcelworld.resolve("java.security.Key").getSuperclass(); - assertTrue("Should be null but is " + bcelSupertype, bcelSupertype.equals(UnresolvedType.OBJECT)); - } - - public void testVoidSuperclass() { - ResolvedType voidType = world.resolve(Void.TYPE); - ResolvedType superType = voidType.getSuperclass(); - assertNull(superType); - - BcelWorld bcelworld = new BcelWorld(); - bcelworld.setBehaveInJava5Way(true); - ResolvedType bcelSupertype = bcelworld.resolve("void").getSuperclass(); - assertTrue("Should be null but is " + bcelSupertype, bcelSupertype == null); - } - - public void testIntSuperclass() { - ResolvedType voidType = world.resolve(Integer.TYPE); - ResolvedType superType = voidType.getSuperclass(); - assertNull(superType); - - BcelWorld bcelworld = new BcelWorld(); - bcelworld.setBehaveInJava5Way(true); - ResolvedType bcelSupertype = bcelworld.resolve("int").getSuperclass(); - assertTrue("Should be null but is " + bcelSupertype, bcelSupertype == null); - } - - public void testGenericInterfaceSuperclass_BcelWorldResolution() { - BcelWorld bcelworld = new BcelWorld(); - bcelworld.setBehaveInJava5Way(true); - - UnresolvedType javaUtilMap = UnresolvedType.forName("java.util.Map"); - - ReferenceType rawType = (ReferenceType) bcelworld.resolve(javaUtilMap); - assertTrue("Should be the raw type ?!? " + rawType.getTypekind(), rawType.isRawType()); - - ReferenceType genericType = (ReferenceType) rawType.getGenericType(); - assertTrue("Should be the generic type ?!? " + genericType.getTypekind(), genericType.isGenericType()); - - ResolvedType rt = rawType.getSuperclass(); - assertTrue("Superclass for Map raw type should be Object but was " + rt, rt.equals(UnresolvedType.OBJECT)); - - ResolvedType rt2 = genericType.getSuperclass(); - assertTrue("Superclass for Map generic type should be Object but was " + rt2, rt2.equals(UnresolvedType.OBJECT)); - } - - // FIXME asc maybe. The reflection list of methods returned doesn't include (the static initializer) ... is that really - // a problem. - public void testCompareSubclassDelegates() { - - boolean barfIfClinitMissing = false; - world.setBehaveInJava5Way(true); - - BcelWorld bcelWorld = new BcelWorld(getClass().getClassLoader(), IMessageHandler.THROW, null); - bcelWorld.setBehaveInJava5Way(true); - UnresolvedType javaUtilHashMap = UnresolvedType.forName("java.util.HashMap"); - ReferenceType rawType = (ReferenceType) bcelWorld.resolve(javaUtilHashMap); - - ReferenceType rawReflectType = (ReferenceType) world.resolve(javaUtilHashMap); - ResolvedMember[] rms1 = rawType.getDelegate().getDeclaredMethods(); - ResolvedMember[] rms2 = rawReflectType.getDelegate().getDeclaredMethods(); - StringBuffer errors = new StringBuffer(); - Set one = new HashSet(); - for (int i = 0; i < rms1.length; i++) { - one.add(rms1[i].toString()); - } - Set two = new HashSet(); - for (int i = 0; i < rms2.length; i++) { - two.add(rms2[i].toString()); - } - for (int i = 0; i < rms2.length; i++) { - if (!one.contains(rms2[i].toString())) { - errors.append("Couldn't find " + rms2[i].toString() + " in the bcel set\n"); - } - } - for (int i = 0; i < rms1.length; i++) { - if (!two.contains(rms1[i].toString())) { - if (!barfIfClinitMissing && rms1[i].getName().equals("")) - continue; - errors.append("Couldn't find " + rms1[i].toString() + " in the reflection set\n"); - } - } - assertTrue("Errors:" + errors.toString(), errors.length() == 0); - - // the good old ibm vm seems to offer clinit through its reflection support (see pr145322) - if (rms1.length == rms2.length) - return; - if (barfIfClinitMissing) { - // the numbers must be exact - assertEquals(rms1.length, rms2.length); - } else { - // the numbers can be out by one in favour of bcel - if (rms1.length != (rms2.length + 1)) { - for (int i = 0; i < rms1.length; i++) { - System.err.println("bcel" + i + " is " + rms1[i]); - } - for (int i = 0; i < rms2.length; i++) { - System.err.println("refl" + i + " is " + rms2[i]); - } - } - assertTrue("Should be one extra (clinit) in BCEL case, but bcel=" + rms1.length + " reflect=" + rms2.length, - rms1.length == rms2.length + 1); - } - } - - public void testArrayArgsSig() throws Exception { - Method invokeMethod = Method.class.getMethod("invoke", new Class[] { Object.class, Object[].class }); - ResolvedMember reflectionMethod = ReflectionBasedReferenceTypeDelegateFactory.createResolvedMethod(invokeMethod, world); - String exp = "(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;"; - assertTrue("Expected: \n" + exp + "\n but got:\n" + reflectionMethod.getSignature(), reflectionMethod.getSignature() - .equals(exp)); - } - - // todo: array of int - - protected void setUp() throws Exception { - world = new ReflectionWorld(getClass().getClassLoader()); - objectType = world.resolve("java.lang.Object"); - } -} diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/reflect/ReflectionWorldReferenceTypeTest.java b/weaver5/java5-testsrc/org/aspectj/weaver/reflect/ReflectionWorldReferenceTypeTest.java deleted file mode 100644 index 720c88289..000000000 --- a/weaver5/java5-testsrc/org/aspectj/weaver/reflect/ReflectionWorldReferenceTypeTest.java +++ /dev/null @@ -1,27 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2002-2008 Contributors - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Andy Clement - * ******************************************************************/ -package org.aspectj.weaver.reflect; - -import org.aspectj.weaver.CommonReferenceTypeTests; -import org.aspectj.weaver.World; - -public class ReflectionWorldReferenceTypeTest extends CommonReferenceTypeTests { - - protected boolean getSupportsAutoboxing() { - return true; - } - - public World getWorld() { - return new ReflectionWorld(false, getClass().getClassLoader()); - } - -} diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/reflect/ReflectionWorldTest.java b/weaver5/java5-testsrc/org/aspectj/weaver/reflect/ReflectionWorldTest.java deleted file mode 100644 index 1108ca13c..000000000 --- a/weaver5/java5-testsrc/org/aspectj/weaver/reflect/ReflectionWorldTest.java +++ /dev/null @@ -1,290 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005,2017 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * ******************************************************************/ -package org.aspectj.weaver.reflect; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.lang.reflect.Type; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.List; -import java.util.Map; - -import org.aspectj.bridge.IMessageHandler; -import org.aspectj.weaver.ReferenceType; -import org.aspectj.weaver.ResolvedMember; -import org.aspectj.weaver.ResolvedType; -import org.aspectj.weaver.UnresolvedType; -import org.aspectj.weaver.WeakClassLoaderReference; -import org.aspectj.weaver.World; -import org.aspectj.weaver.bcel.BcelWorld; - -import junit.framework.TestCase; - -/** - * @author Andy Clement - * @author Adrian Colyer - */ -public class ReflectionWorldTest extends TestCase { - - public void testDelegateCreation() { - World world = new ReflectionWorld(getClass().getClassLoader()); - ResolvedType rt = world.resolve("java.lang.Object"); - assertNotNull(rt); - assertEquals("Ljava/lang/Object;", rt.getSignature()); - } - - // Removed for now. In Spring the reflection worlds are customized by introducing new - // PCD handlers. It means more thought needs to be put into reusing worlds. - public void xtestReflectionWorldFactory() throws Exception { - ClassLoader parent = getClass().getClassLoader(); - ClassLoader cl1 = new URLClassLoader(new URL[] {}, parent); - ClassLoader cl2 = new URLClassLoader(new URL[] {}, parent); - - WeakClassLoaderReference wcl1 = new WeakClassLoaderReference(cl1); - WeakClassLoaderReference wcl2 = new WeakClassLoaderReference(cl2); - ReflectionWorld a = ReflectionWorld.getReflectionWorldFor(wcl1); - - ResolvedType stringClass1 = a.resolve(String.class); - assertNotNull(stringClass1); - - ReflectionWorld b = ReflectionWorld.getReflectionWorldFor(wcl1); - - // They should be the same because the classloader has not gone away - assertTrue(a==b); - - cl1 = null; - for (int i=0;i<100;i++) { - System.gc(); // How robust is it that this should be causing the reference to be collected? - } - b = ReflectionWorld.getReflectionWorldFor(wcl1); - - assertFalse(a==b); - - cl1 = new URLClassLoader(new URL[] {}, parent); - wcl1 = new WeakClassLoaderReference(cl1); - a = ReflectionWorld.getReflectionWorldFor(wcl1); - b = ReflectionWorld.getReflectionWorldFor(wcl2); - assertFalse(a==b); - - Field declaredField = ReflectionWorld.class.getDeclaredField("rworlds"); - declaredField.setAccessible(true); - Map worlds = (Map)declaredField.get(null); - assertEquals(2, worlds.size()); - - cl2 = null; - for (int i=0;i<100;i++) { - System.gc(); // How robust is it that this should be causing the reference to be collected? - } - ReflectionWorld.getReflectionWorldFor(wcl1); // need to call this to trigger tidyup - assertEquals(1, worlds.size()); - - cl1 = null; - for (int i=0;i<100;i++) { - System.gc(); // How robust is it that this should be causing the reference to be collected? - } - ReflectionWorld.getReflectionWorldFor(wcl1); // need to call this to trigger tidyup - assertEquals(0, worlds.size()); - - cl1 = new URLClassLoader(new URL[] {}, parent); - wcl1 = new WeakClassLoaderReference(cl1); - ReflectionWorld reflectionWorldFor = ReflectionWorld.getReflectionWorldFor(wcl1); - assertEquals(1, worlds.size()); - ReflectionWorld.cleanUpWorlds(); - assertEquals(0, worlds.size()); - } - - public void testArrayTypes() { - IReflectionWorld world = new ReflectionWorld(getClass().getClassLoader()); - String[] strArray = new String[1]; - ResolvedType rt = world.resolve(strArray.getClass()); - assertTrue(rt.isArray()); - } - - public void testPrimitiveTypes() { - IReflectionWorld world = new ReflectionWorld(getClass().getClassLoader()); - assertEquals("int", UnresolvedType.INT, world.resolve(int.class)); - assertEquals("void", UnresolvedType.VOID, world.resolve(void.class)); - } - - static class AbstractSuperClass {} - static interface InterfaceOne {} - static interface InterfaceTwo {} - static class ID {} - static abstract class AbstractTestClass extends AbstractSuperClass implements InterfaceOne, InterfaceTwo { - - } - static class TestType {} -// static class ConcreteClass extends AbstractTestClass { - static class ConcreteClass extends AbstractTestClass> { - } - - static class Bar extends ConcreteClass {} - - public void testGenerics() { - ReflectionWorld world = new ReflectionWorld(getClass().getClassLoader()); -// world.lookupOrCreateName(UnresolvedType.forName(AbstractTestClass.class.getName())); -// ResolvedType resolvedType = world.resolve(AbstractTestClass.class); - JavaLangTypeToResolvedTypeConverter converter = new JavaLangTypeToResolvedTypeConverter(world); - ResolvedType resolvedType2 = converter.fromType(ConcreteClass.class); - } - - public void testTypeConversions_509327() throws Exception { - ReflectionWorld rWorld = new ReflectionWorld(getClass().getClassLoader()); - JavaLangTypeToResolvedTypeConverter converter = new JavaLangTypeToResolvedTypeConverter(rWorld); - - // Check basic conversion of String to String - Method method = TestClass.class.getDeclaredMethod("m"); - Type stringType = method.getGenericReturnType(); - assertEquals("java.lang.String",stringType.getTypeName()); - ResolvedType stringResolvedType = converter.fromType(stringType); - assertEquals("java.lang.String",stringResolvedType.getName()); - - // public String m() { return ""; } - method = TestClass2.class.getDeclaredMethod("m"); - stringType = method.getGenericReturnType(); - assertEquals("java.lang.String",stringType.getTypeName()); - stringResolvedType = converter.fromType(stringType); - assertEquals("java.lang.String",stringResolvedType.getName()); - - // Verify that the conversion process creates the same thing as the bcel unpacking - - // Here the return type is a non-static inner of a generic class - // public Inner m2() { return null; } - method = TestClass2.class.getDeclaredMethod("m2"); - Type innerType = method.getGenericReturnType(); - assertEquals("org.aspectj.weaver.reflect.ReflectionWorldTest.org.aspectj.weaver.reflect.ReflectionWorldTest$TestClass2.Inner",innerType.getTypeName()); - ResolvedType rType_Inner = converter.fromType(innerType); - assertEquals("Lorg/aspectj/weaver/reflect/ReflectionWorldTest$TestClass2$Inner;",rType_Inner.getSignature()); - assertEquals(UnresolvedType.TypeKind.SIMPLE,rType_Inner.getTypekind()); - ResolvedType rType_Outer = rType_Inner.getOuterClass(); - assertEquals("Lorg/aspectj/weaver/reflect/ReflectionWorldTest$TestClass2;",rType_Outer.getSignature()); - - BcelWorld bWorld = new BcelWorld(getClass().getClassLoader(), IMessageHandler.THROW, null); - bWorld.setBehaveInJava5Way(true); - UnresolvedType javaUtilHashMap = UnresolvedType.forName("java.util.HashMap"); - ReferenceType rawType = (ReferenceType) bWorld.resolve(javaUtilHashMap); - assertNotNull(rawType); - - // Now use bcel to resolve the same m2 method, and compare the signatures of the return types - ResolvedType bResolved_TestClass2 = bWorld.resolve(UnresolvedType.forName(TestClass2.class.getName())); - assertNotNull(bResolved_TestClass2); - ResolvedMember bMethod_m2 = findMethod(bResolved_TestClass2,"m2"); - ResolvedType bType_Inner = (ResolvedType) bMethod_m2.getReturnType(); - assertEquals("Lorg/aspectj/weaver/reflect/ReflectionWorldTest$TestClass2$Inner;",bType_Inner.getSignature()); - assertEquals(UnresolvedType.TypeKind.SIMPLE,bType_Inner.getTypekind()); - ResolvedType bType_Outer = bType_Inner.getOuterClass(); - assertEquals("Lorg/aspectj/weaver/reflect/ReflectionWorldTest$TestClass2;",bType_Outer.getSignature()); - - assertEquals(bType_Inner.getSignature(),rType_Inner.getSignature()); - assertEquals(bType_Outer.getSignature(),rType_Outer.getSignature()); - } - - - public void testTypeConversions_509327_2() throws Exception { - ReflectionWorld world = new ReflectionWorld(getClass().getClassLoader()); - JavaLangTypeToResolvedTypeConverter converter = new JavaLangTypeToResolvedTypeConverter(world); - BcelWorld bWorld = new BcelWorld(getClass().getClassLoader(), IMessageHandler.THROW, null); - bWorld.setBehaveInJava5Way(true); - - // Slightly more advanced, now the method is returning a parameterized form of the outer - // generic class - - // public TestClass2.Inner m3() { return new TestClass2.Inner("Foo"); } - Method method = TestClass2.class.getDeclaredMethod("m3"); - Type type_ParameterizedInner = method.getGenericReturnType(); - assertEquals("org.aspectj.weaver.reflect.ReflectionWorldTest.org.aspectj.weaver.reflect.ReflectionWorldTest$TestClass2.Inner",type_ParameterizedInner.getTypeName()); - ResolvedType rType_ParameterizedInner = converter.fromType(type_ParameterizedInner); - // NOTE: DECLARED PARAMETERIZATION OF OUTER IS LOST - assertEquals("Lorg/aspectj/weaver/reflect/ReflectionWorldTest$TestClass2$Inner;",rType_ParameterizedInner.getSignature()); - - ResolvedType bResolved_TestClass2 = bWorld.resolve(UnresolvedType.forName(TestClass2.class.getName())); - assertNotNull(bResolved_TestClass2); - ResolvedMember bMethod_m3 = findMethod(bResolved_TestClass2,"m3"); - ResolvedType bType_Inner = (ResolvedType) bMethod_m3.getReturnType(); - // NOTE: DECLARED PARAMETERIZATION OF OUTER IS LOST - assertEquals("Lorg/aspectj/weaver/reflect/ReflectionWorldTest$TestClass2$Inner;",bType_Inner.getSignature()); - - assertEquals(UnresolvedType.TypeKind.SIMPLE,bType_Inner.getTypekind()); - ResolvedType bType_Outer = bType_Inner.getOuterClass(); - - // Fields seem to lose it too, although the backinggenericmember has the info -// ResolvedMember bField_f = findField(bResolved_TestClass2,"f"); -// ResolvedMember backingGenericMember = bField_f.getBackingGenericMember(); -// System.out.println(backingGenericMember); -// System.out.println(backingGenericMember.getGenericReturnType()); -// System.out.println(bField_f); -// System.out.println(bField_f.getSignature()); -// System.out.println(bField_f.getGenericReturnType()); - } - -// public void testbar() throws Exception { -// ReflectionWorld world = new ReflectionWorld(getClass().getClassLoader()); -// JavaLangTypeToResolvedTypeConverter converter = new JavaLangTypeToResolvedTypeConverter(world); -// -// // public TestClass2.Inner m3() { return new TestClass2.Inner("Foo"); } -// Method method = TestClass2.class.getDeclaredMethod("m3"); -// Type type_ParameterizedInner = method.getGenericReturnType(); -// assertEquals("org.aspectj.weaver.reflect.ReflectionWorldTest.org.aspectj.weaver.reflect.ReflectionWorldTest$TestClass2.Inner",type_ParameterizedInner.getTypeName()); -// ResolvedType rType_ParameterizedInner = converter.fromType(type_ParameterizedInner); -// System.out.println(rType_ParameterizedInner); -// System.out.println(type_ParameterizedInner.getTypeName()); -// } -// -// public void testfoo() { -// ReflectionWorld world = new ReflectionWorld(getClass().getClassLoader()); -// JavaLangTypeToResolvedTypeConverter converter = new JavaLangTypeToResolvedTypeConverter(world); -// BcelWorld bWorld = new BcelWorld(getClass().getClassLoader(), IMessageHandler.THROW, null); -// bWorld.setBehaveInJava5Way(true); -// -// -// ResolvedType bResolved_TestClass2 = bWorld.resolve(UnresolvedType.forName(TestClass2.class.getName())); -// ResolvedMember bField_f = findField(bResolved_TestClass2,"f"); -// System.out.println(bField_f); -// System.out.println(bField_f.getGenericReturnType()); -// System.out.println(bField_f.getReturnType()); -// System.out.println(bField_f.getBackingGenericMember().getGenericReturnType()); -// } - - static class TestClass { - public String m() { return ""; } - } - - static class TestClass2 { - class Inner { - T t; - Inner(T t) { - this.t = t; - } - } - public String m() { return ""; } - public Inner m2() { return null; } - public TestClass2 f; - public TestClass2.Inner m3() { return new TestClass2.Inner("Foo"); } - } - - private ResolvedMember findMethod(ResolvedType resolvedType, String methodName) { - for (ResolvedMember method: resolvedType.getDeclaredMethods()) { - if (method.getName().equals(methodName)) { - return method; - } - } - return null; - } - - private ResolvedMember findField(ResolvedType resolvedType, String fieldName) { - for (ResolvedMember field: resolvedType.getDeclaredFields()) { - if (field.getName().equals(fieldName)) { - return field; - } - } - return null; - } - -} diff --git a/weaver5/java5-testsrc/org/aspectj/weaver/tools/Java15PointcutExpressionTest.java b/weaver5/java5-testsrc/org/aspectj/weaver/tools/Java15PointcutExpressionTest.java deleted file mode 100644 index f651a2f29..000000000 --- a/weaver5/java5-testsrc/org/aspectj/weaver/tools/Java15PointcutExpressionTest.java +++ /dev/null @@ -1,746 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.weaver.tools; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; -import java.util.StringTokenizer; - -import org.aspectj.lang.annotation.Pointcut; -import org.aspectj.weaver.ResolvedType; -import org.aspectj.weaver.internal.tools.PointcutExpressionImpl; -import org.aspectj.weaver.patterns.AbstractPatternNodeVisitor; -import org.aspectj.weaver.patterns.AndAnnotationTypePattern; -import org.aspectj.weaver.patterns.AnnotationPatternList; -import org.aspectj.weaver.patterns.AnyAnnotationTypePattern; -import org.aspectj.weaver.patterns.BindingAnnotationTypePattern; -import org.aspectj.weaver.patterns.ExactAnnotationTypePattern; -import org.aspectj.weaver.patterns.KindedPointcut; -import org.aspectj.weaver.patterns.NotAnnotationTypePattern; -import org.aspectj.weaver.patterns.OrAnnotationTypePattern; -import org.aspectj.weaver.patterns.SignaturePattern; -import org.aspectj.weaver.patterns.TypePattern; -import org.aspectj.weaver.patterns.TypePatternList; -import org.aspectj.weaver.patterns.WildAnnotationTypePattern; - -import test.A1AnnotatedType; -import test.A2AnnotatedType; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -/** - * Test parameter pointcut parsing. Extended by Andy Clement to cover parameter annotation matching. - * - */ -public class Java15PointcutExpressionTest extends TestCase { - - public static Test suite() { - TestSuite suite = new TestSuite("Java15PointcutExpressionTest"); - suite.addTestSuite(Java15PointcutExpressionTest.class); - return suite; - } - - private PointcutParser parser; - private Method a; - private Method b; - private Method c; - private Method d; - - /** - * Parse some expressions and ensure we capture the parameter annotations and parameter type annotations correctly. - * Buckle up, this will get complicated ;) - */ - public void testParseParameterAnnotationExpressions() { - PointcutParser p = PointcutParser.getPointcutParserSupportingAllPrimitivesAndUsingSpecifiedClassloaderForResolution(this.getClass().getClassLoader()); - PointcutExpression pexpr = null; - - pexpr = p.parsePointcutExpression("execution(public void foo(@MA *))"); - checkParameterAnnotations(pexpr,0,null,"@MA","exact[@MA:t]"); - - pexpr = p.parsePointcutExpression("execution(public void foo(@MA (*)))"); - checkParameterAnnotations(pexpr,0,"@MA",null,"exact[@MA:p]"); - - pexpr = p.parsePointcutExpression("execution(public void foo(@MA @MB *))"); - checkParameterAnnotations(pexpr,0,null,"@MA @MB","(exact[@MA:t] and exact[@MB:t])"); - - pexpr = p.parsePointcutExpression("execution(public void foo(@MA (@MB *)))"); - checkParameterAnnotations(pexpr,0,"@MA","@MB","(exact[@MA:p] and exact[@MB:t])"); - - pexpr = p.parsePointcutExpression("execution(public void foo(@MA @MB (@MC *)))"); - checkParameterAnnotations(pexpr,0,"@MA @MB","@MC","((exact[@MA:p] and exact[@MB:p]) and exact[@MC:t])"); - - pexpr = p.parsePointcutExpression("execution(public void foo(@MA (@MB @MC @MD *)))"); - checkParameterAnnotations(pexpr,0,"@MA","@MB @MC @MD","(exact[@MA:p] and ((exact[@MB:t] and exact[@MC:t]) and exact[@MD:t]))"); - - pexpr = p.parsePointcutExpression("execution(public void foo(@(MA || MB) (@MC @MD *)))"); - checkParameterAnnotations(pexpr,0,null/*Should be MA MB */,"@MC @MD","(wild[(MA || MB)] and (exact[@MC:t] and exact[@MD:t]))"); // I dont think WildAnnotationTypePatterns work properly... - - pexpr = p.parsePointcutExpression("execution(public void foo(@MA (@MB *),(@MC *),@MD (*)))"); - checkParameterAnnotations(pexpr,0,"@MA","@MB","(exact[@MA:p] and exact[@MB:t])"); - checkParameterAnnotations(pexpr,1,null,"@MC","exact[@MC:t]"); - checkParameterAnnotations(pexpr,2,"@MD",null,"exact[@MD:p]"); - - } - - public void testMatchingAnnotationValueExpressions() throws SecurityException, NoSuchMethodException { - PointcutParser p = PointcutParser.getPointcutParserSupportingAllPrimitivesAndUsingSpecifiedClassloaderForResolution(this.getClass().getClassLoader()); - PointcutExpression pexpr = null; - ShadowMatch match = null; - - Method n = test.AnnoValues.class.getMethod("none"); - Method r = test.AnnoValues.class.getMethod("redMethod"); - Method g = test.AnnoValues.class.getMethod("greenMethod"); - Method b = test.AnnoValues.class.getMethod("blueMethod"); - Method d = test.AnnoValues.class.getMethod("defaultMethod"); - - pexpr = p.parsePointcutExpression("execution(@test.A3(test.Color.RED) public void *(..))"); - assertTrue("Should match", pexpr.matchesMethodExecution(n).neverMatches()); // default value RED - assertTrue("Should match", pexpr.matchesMethodExecution(r).alwaysMatches()); - assertTrue("Should not match", pexpr.matchesMethodExecution(g).neverMatches()); - assertTrue("Should not match", pexpr.matchesMethodExecution(b).neverMatches()); - assertTrue("Should match", pexpr.matchesMethodExecution(d).alwaysMatches()); - - pexpr = p.parsePointcutExpression("execution(@test.A3(test.Color.GREEN) public void *(..))"); - assertTrue("Should not match", pexpr.matchesMethodExecution(n).neverMatches()); // default value RED - assertTrue("Should not match", pexpr.matchesMethodExecution(r).neverMatches()); - assertTrue("Should match", pexpr.matchesMethodExecution(g).alwaysMatches()); - assertTrue("Should not match", pexpr.matchesMethodExecution(b).neverMatches()); - assertTrue("Should not match", pexpr.matchesMethodExecution(d).neverMatches()); - - pexpr = p.parsePointcutExpression("execution(@test.A3(test.Color.BLUE) public void *(..))"); - assertTrue("Should not match", pexpr.matchesMethodExecution(n).neverMatches()); // default value RED - assertTrue("Should not match", pexpr.matchesMethodExecution(r).neverMatches()); - assertTrue("Should not match", pexpr.matchesMethodExecution(g).neverMatches()); - assertTrue("Should match", pexpr.matchesMethodExecution(b).alwaysMatches()); - assertTrue("Should not match", pexpr.matchesMethodExecution(d).neverMatches()); - - pexpr = p.parsePointcutExpression("execution(@test.A3 public void *(..))"); - assertTrue("Should match", pexpr.matchesMethodExecution(n).neverMatches()); // default value RED - assertTrue("Should match", pexpr.matchesMethodExecution(r).alwaysMatches()); - assertTrue("Should match", pexpr.matchesMethodExecution(g).alwaysMatches()); - assertTrue("Should match", pexpr.matchesMethodExecution(b).alwaysMatches()); - assertTrue("Should match", pexpr.matchesMethodExecution(d).alwaysMatches()); - - } - - private static final Set DEFAULT_SUPPORTED_PRIMITIVES = new HashSet(); - - static { - DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.EXECUTION); - DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.ARGS); - DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.REFERENCE); - DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.THIS); - DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.TARGET); - DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.WITHIN); - DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.AT_ANNOTATION); - DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.AT_WITHIN); - DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.AT_ARGS); - DEFAULT_SUPPORTED_PRIMITIVES.add(PointcutPrimitive.AT_TARGET); - } - - public void testPerformanceOfPointcutParsing() { - String expression = "execution(public * rewards.internal.*.*Repository+.*(..))"; - long stime1 = System.currentTimeMillis(); - PointcutParser parser = PointcutParser.getPointcutParserSupportingSpecifiedPrimitivesAndUsingContextClassloaderForResolution(DEFAULT_SUPPORTED_PRIMITIVES); - long stime2 = System.currentTimeMillis(); - PointcutExpression pointcutExpression = parser.parsePointcutExpression(expression, null, new PointcutParameter[0]); - long etime = System.currentTimeMillis(); - System.out.println("Time to get a parser "+(stime2-stime1)+"ms"); - System.out.println("Time taken to parse expression is "+(etime-stime2)+"ms"); - } - - - public void testPerformanceOfPointcutParsingWithBean() { - String expression = "execution(public * rewards.internal.*.*Repository+.*(..))"; - PointcutParser parser = PointcutParser.getPointcutParserSupportingAllPrimitivesAndUsingSpecifiedClassloaderForResolution(this.getClass().getClassLoader()); - BeanDesignatorHandler beanHandler = new BeanDesignatorHandler(); - parser.registerPointcutDesignatorHandler(beanHandler); - long stime = System.currentTimeMillis(); - PointcutExpression pointcutExpression = parser.parsePointcutExpression(expression, null, new PointcutParameter[0]); - long etime = System.currentTimeMillis(); - System.out.println("Time taken to parse expression is "+(etime-stime)+"ms"); - } - - private class BeanDesignatorHandler implements PointcutDesignatorHandler { - - private String askedToParse; - public boolean simulateDynamicTest = false; - - public String getDesignatorName() { - return "bean"; - } - - /* (non-Javadoc) - * @see org.aspectj.weaver.tools.PointcutDesignatorHandler#parse(java.lang.String) - */ - public ContextBasedMatcher parse(String expression) { - this.askedToParse = expression; - return null; -// return new BeanPointcutExpression(expression,this.simulateDynamicTest); - } - - public String getExpressionLastAskedToParse() { - return this.askedToParse; - } - } - - - /** - * Test matching of pointcuts against expressions. A reflection world is being used on the backend here (not a Bcel one). - */ - public void testMatchingParameterAnnotationExpressions() throws SecurityException, NoSuchMethodException { - PointcutParser p = PointcutParser.getPointcutParserSupportingAllPrimitivesAndUsingSpecifiedClassloaderForResolution(this.getClass().getClassLoader()); - PointcutExpression pexpr = null; - ShadowMatch match = null; - - Method a = test.A.class.getMethod("a",new Class[] {String.class}); // public void a(String s) {} - Method b = test.A.class.getMethod("b",new Class[] {String.class}); // public void b(@A1 String s) {} - Method c = test.A.class.getMethod("c",new Class[] {String.class}); // public void c(@A1 @A2 String s) {} -// Method d = test.A.class.getMethod("d",new Class[] {String.class,String.class});// public void d(@A1 String s,@A2 String t) {} - - Method e = test.A.class.getMethod("e",new Class[] {A1AnnotatedType.class}); // public void e(A1AnnotatedType s) {} - Method f = test.A.class.getMethod("f",new Class[] {A2AnnotatedType.class}); // public void f(A2AnnotatedType s) {} - Method g = test.A.class.getMethod("g",new Class[] {A1AnnotatedType.class}); // public void g(@A2 A1AnnotatedType s) {} - Method h = test.A.class.getMethod("h",new Class[] {A1AnnotatedType.class}); // public void h(@A1 A1AnnotatedType s) {} -// Method i = test.A.class.getMethod("i",new Class[] {A1AnnotatedType.class,String.class}); // public void i(A1AnnotatedType s,@A2 String t) {} -// Method j = test.A.class.getMethod("j",new Class[] {String.class}); // public void j(@A1 @A2 String s) {} - - pexpr = p.parsePointcutExpression("execution(public void *(@test.A1 *))"); - assertTrue("Should not match", pexpr.matchesMethodExecution(a).neverMatches()); - assertTrue("Should not match", pexpr.matchesMethodExecution(b).neverMatches()); - assertTrue("Should not match", pexpr.matchesMethodExecution(c).neverMatches()); - - pexpr = p.parsePointcutExpression("execution(public void *(@test.A1 (*)))"); - assertTrue("Should not match", pexpr.matchesMethodExecution(a).neverMatches()); - assertTrue("Should match", pexpr.matchesMethodExecution(b).alwaysMatches()); - assertTrue("Should match", pexpr.matchesMethodExecution(c).alwaysMatches()); - - pexpr = p.parsePointcutExpression("execution(public void *(@test.A1 *))"); - assertTrue("Should match", pexpr.matchesMethodExecution(e).alwaysMatches()); - assertTrue("Should not match", pexpr.matchesMethodExecution(f).neverMatches()); - assertTrue("Should match", pexpr.matchesMethodExecution(g).alwaysMatches()); - assertTrue("Should match", pexpr.matchesMethodExecution(h).alwaysMatches()); - - pexpr = p.parsePointcutExpression("execution(public void *(@test.A1 (*)))"); - assertTrue("Should not match", pexpr.matchesMethodExecution(e).neverMatches()); - assertTrue("Should not match", pexpr.matchesMethodExecution(f).neverMatches()); - assertTrue("Should not match", pexpr.matchesMethodExecution(g).neverMatches()); - assertTrue("Should match", pexpr.matchesMethodExecution(h).alwaysMatches()); - - pexpr = p.parsePointcutExpression("execution(public void *(@(test.A1 || test.A2) (*)))"); - assertTrue("Should not match", pexpr.matchesMethodExecution(a).neverMatches()); - assertTrue("Should match", pexpr.matchesMethodExecution(b).alwaysMatches()); - assertTrue("Should match", pexpr.matchesMethodExecution(c).alwaysMatches()); - assertTrue("Should match", pexpr.matchesMethodExecution(g).alwaysMatches()); - assertTrue("Should match", pexpr.matchesMethodExecution(h).alwaysMatches()); - - pexpr = p.parsePointcutExpression("execution(public void *(@(test.A1 && test.A2) (*),..))"); - assertTrue("Should not match", pexpr.matchesMethodExecution(a).neverMatches()); - assertTrue("Should not match", pexpr.matchesMethodExecution(b).neverMatches()); - assertTrue("Should not match", pexpr.matchesMethodExecution(c).neverMatches()); - assertTrue("Should not match", pexpr.matchesMethodExecution(g).neverMatches()); - assertTrue("Should not match", pexpr.matchesMethodExecution(h).neverMatches()); -// assertTrue("Should match", pexpr.matchesMethodExecution(j).alwaysMatches()); // should match but does not, broken implementation, old bug - see WildAnnotationTypePattern.match - - - - } - - private void checkParameterAnnotations(PointcutExpression pe,int parameterNumber,String expectedParameterAnnotations,String expectedParameterTypeAnnotations,String expectedNodeStructure) { - org.aspectj.weaver.patterns.Pointcut p = ((PointcutExpressionImpl)pe).getUnderlyingPointcut(); - KindedPointcut kindedP = (KindedPointcut)p; - SignaturePattern sp = kindedP.getSignature(); - TypePatternList tpl = sp.getParameterTypes(); - TypePattern[] tps = tpl.getTypePatterns(); - - // A visitor over the annotation pattern for the parameter will break it down into parameter vs parameter type annotations - MyPatternNodeVisitor mpnv = new MyPatternNodeVisitor(); - tps[parameterNumber].getAnnotationPattern().accept(mpnv,null); - - if (expectedNodeStructure==null) { - // The caller hasn't worked it out yet!! - System.out.println(mpnv.getStringRepresentation()); - } else if (!mpnv.getStringRepresentation().equals(expectedNodeStructure)) { - System.out.println(mpnv.getStringRepresentation()); - fail("Expected annotation pattern node structure for expression "+pe.getPointcutExpression()+ - " was '"+expectedNodeStructure+"' but it turned out to be '"+mpnv.getStringRepresentation()+"'"); - } - - tps[parameterNumber].getAnnotationPattern().toString(); - - // parameter type annotation checking - Set expected = new HashSet(); - expected.addAll(mpnv.getParameterTypeAnnotations()); - - StringTokenizer st = new StringTokenizer(expectedParameterTypeAnnotations==null?"":expectedParameterTypeAnnotations); - while (st.hasMoreTokens()) { - String nextToken = st.nextToken(); - if (!expected.contains(nextToken)) - fail("In pointcut expression "+pe.getPointcutExpression()+" parameter "+parameterNumber+". The annotation type pattern did not include parameter type annotation "+nextToken+". It's full set was "+mpnv.getParameterTypeAnnotations()); - expected.remove(nextToken); - } - if (expected.size()>0) { // we have excess ones! - StringBuffer excessTokens = new StringBuffer(); - for (Iterator iterator = expected.iterator(); iterator.hasNext();) { - String string = (String) iterator.next(); - excessTokens.append(string).append(" "); - } - fail("In pointcut expression "+pe.getPointcutExpression()+" parameter "+parameterNumber+". The annotation type pattern has these unexpected parameter type annotations "+excessTokens.toString()); - } - - // parameter annotation checking - expected = new HashSet(); - expected.addAll(mpnv.getParameterAnnotations()); - - st = new StringTokenizer(expectedParameterAnnotations==null?"":expectedParameterAnnotations); - while (st.hasMoreTokens()) { - String nextToken = st.nextToken(); - if (!expected.contains(nextToken)) - fail("In pointcut expression "+pe.getPointcutExpression()+" parameter "+parameterNumber+". The annotation type pattern did not include parameter annotation "+nextToken+". It's full set was "+mpnv.getParameterAnnotations()); - expected.remove(nextToken); - } - if (expected.size()>0) { // we have excess ones! - StringBuffer excessTokens = new StringBuffer(); - for (Iterator iterator = expected.iterator(); iterator.hasNext();) { - String string = (String) iterator.next(); - excessTokens.append(string).append(" "); - } - fail("In pointcut expression "+pe.getPointcutExpression()+" parameter "+parameterNumber+". The annotation type pattern has these unexpected parameter annotations "+excessTokens.toString()); - } - - } - - static class MyPatternNodeVisitor extends AbstractPatternNodeVisitor { - private StringBuffer stringRep = new StringBuffer(); - private List parameterAnnotations = new ArrayList(); - private List parameterTypeAnnotations = new ArrayList(); - - public String getStringRepresentation() { return stringRep.toString(); } - public List getParameterAnnotations() { return parameterAnnotations; } - public List getParameterTypeAnnotations() { return parameterTypeAnnotations; } - - public Object visit(AndAnnotationTypePattern node, Object data) { - stringRep.append("("); - node.getLeft().accept(this, data); - stringRep.append(" and "); - node.getRight().accept(this, data); - stringRep.append(")"); - return node; - } - public Object visit(AnyAnnotationTypePattern node, Object data) { - stringRep.append("any"); - return node; - } - public Object visit(ExactAnnotationTypePattern node, Object data) { - stringRep.append("exact["+stringify(node.getResolvedAnnotationType())+":"+(node.isForParameterAnnotationMatch()?"p":"t")+"]"); - if (node.isForParameterAnnotationMatch()) { - parameterAnnotations.add(stringify(node.getResolvedAnnotationType())); - } else { - parameterTypeAnnotations.add(stringify(node.getResolvedAnnotationType())); - } - return node; - } - private String stringify(ResolvedType resolvedAnnotationType) { - return "@"+resolvedAnnotationType.getSimpleName(); - } - - public Object visit(BindingAnnotationTypePattern node, Object data) { - stringRep.append("binding"); - - return node; - } - public Object visit(NotAnnotationTypePattern node, Object data) { - stringRep.append("not"); - return node; - } - public Object visit(OrAnnotationTypePattern node, Object data) { - stringRep.append("("); - node.getLeft().accept(this, data); - stringRep.append(" or "); - node.getRight().accept(this, data); - stringRep.append(")"); - return node; - } - public Object visit(WildAnnotationTypePattern node, Object data) { - stringRep.append("wild["); - stringRep.append(node.getTypePattern().toString()); - stringRep.append("]"); - return node; - } - public Object visit(AnnotationPatternList node, Object data) { - stringRep.append("list"); - - return node; - } - - - } - - - - public void testAtThis() { - PointcutExpression atThis = parser.parsePointcutExpression("@this(org.aspectj.weaver.tools.Java15PointcutExpressionTest.MyAnnotation)"); - ShadowMatch sMatch1 = atThis.matchesMethodExecution(a); - ShadowMatch sMatch2 = atThis.matchesMethodExecution(b); - assertTrue("maybe matches A",sMatch1.maybeMatches()); - assertTrue("maybe matches B",sMatch2.maybeMatches()); - JoinPointMatch jp1 = sMatch1.matchesJoinPoint(new A(), new A(), new Object[0]); - assertFalse("does not match",jp1.matches()); - JoinPointMatch jp2 = sMatch2.matchesJoinPoint(new B(), new B(), new Object[0]); - assertTrue("matches",jp2.matches()); - } - - public void testAtTarget() { - PointcutExpression atTarget = parser.parsePointcutExpression("@target(org.aspectj.weaver.tools.Java15PointcutExpressionTest.MyAnnotation)"); - ShadowMatch sMatch1 = atTarget.matchesMethodExecution(a); - ShadowMatch sMatch2 = atTarget.matchesMethodExecution(b); - assertTrue("maybe matches A",sMatch1.maybeMatches()); - assertTrue("maybe matches B",sMatch2.maybeMatches()); - JoinPointMatch jp1 = sMatch1.matchesJoinPoint(new A(), new A(), new Object[0]); - assertFalse("does not match",jp1.matches()); - JoinPointMatch jp2 = sMatch2.matchesJoinPoint(new B(), new B(), new Object[0]); - assertTrue("matches",jp2.matches()); - } - - public void testAtThisWithBinding() { - PointcutParameter param = parser.createPointcutParameter("a",MyAnnotation.class); - B myB = new B(); - MyAnnotation bAnnotation = B.class.getAnnotation(MyAnnotation.class); - PointcutExpression atThis = parser.parsePointcutExpression("@this(a)",A.class,new PointcutParameter[] {param}); - ShadowMatch sMatch1 = atThis.matchesMethodExecution(a); - ShadowMatch sMatch2 = atThis.matchesMethodExecution(b); - assertTrue("maybe matches A",sMatch1.maybeMatches()); - assertTrue("maybe matches B",sMatch2.maybeMatches()); - JoinPointMatch jp1 = sMatch1.matchesJoinPoint(new A(), new A(), new Object[0]); - assertFalse("does not match",jp1.matches()); - JoinPointMatch jp2 = sMatch2.matchesJoinPoint(myB, myB, new Object[0]); - assertTrue("matches",jp2.matches()); - assertEquals(1,jp2.getParameterBindings().length); - assertEquals("should be myB's annotation",bAnnotation,jp2.getParameterBindings()[0].getBinding()); - } - - public void testAtTargetWithBinding() { - PointcutParameter param = parser.createPointcutParameter("a",MyAnnotation.class); - B myB = new B(); - MyAnnotation bAnnotation = B.class.getAnnotation(MyAnnotation.class); - PointcutExpression atThis = parser.parsePointcutExpression("@target(a)",A.class,new PointcutParameter[] {param}); - ShadowMatch sMatch1 = atThis.matchesMethodExecution(a); - ShadowMatch sMatch2 = atThis.matchesMethodExecution(b); - assertTrue("maybe matches A",sMatch1.maybeMatches()); - assertTrue("maybe matches B",sMatch2.maybeMatches()); - JoinPointMatch jp1 = sMatch1.matchesJoinPoint(new A(), new A(), new Object[0]); - assertFalse("does not match",jp1.matches()); - JoinPointMatch jp2 = sMatch2.matchesJoinPoint(myB, myB, new Object[0]); - assertTrue("matches",jp2.matches()); - assertEquals(1,jp2.getParameterBindings().length); - assertEquals("should be myB's annotation",bAnnotation,jp2.getParameterBindings()[0].getBinding()); - } - - public void testAtArgs() { - PointcutExpression atArgs = parser.parsePointcutExpression("@args(..,org.aspectj.weaver.tools.Java15PointcutExpressionTest.MyAnnotation)"); - ShadowMatch sMatch1 = atArgs.matchesMethodExecution(a); - ShadowMatch sMatch2 = atArgs.matchesMethodExecution(c); - assertTrue("never matches A",sMatch1.neverMatches()); - assertTrue("maybe matches C",sMatch2.maybeMatches()); - JoinPointMatch jp2 = sMatch2.matchesJoinPoint(new B(), new B(), new Object[]{new A(),new B()}); - assertTrue("matches",jp2.matches()); - - atArgs = parser.parsePointcutExpression("@args(org.aspectj.weaver.tools.Java15PointcutExpressionTest.MyAnnotation,org.aspectj.weaver.tools.Java15PointcutExpressionTest.MyAnnotation)"); - sMatch1 = atArgs.matchesMethodExecution(a); - sMatch2 = atArgs.matchesMethodExecution(c); - assertTrue("never matches A",sMatch1.neverMatches()); - assertTrue("maybe matches C",sMatch2.maybeMatches()); - JoinPointMatch jp1 = sMatch2.matchesJoinPoint(new A(), new A(), new Object[] {new A(), new B()}); - assertFalse("does not match",jp1.matches()); - jp2 = sMatch2.matchesJoinPoint(new B(), new B(), new Object[] {new B(),new B()}); - assertTrue("matches",jp2.matches()); - } - - public void testAtArgs2() { - PointcutExpression atArgs = parser.parsePointcutExpression("@args(*, org.aspectj.weaver.tools.Java15PointcutExpressionTest.MyAnnotation)"); - ShadowMatch sMatch1 = atArgs.matchesMethodExecution(c); - ShadowMatch sMatch2 = atArgs.matchesMethodExecution(d); - assertTrue("maybe matches c",sMatch1.maybeMatches()); - assertTrue("maybe matches d",sMatch2.maybeMatches()); - JoinPointMatch jp1 = sMatch1.matchesJoinPoint(new B(), new B(), new Object[] {new A(), new B()}); - assertTrue("matches",jp1.matches()); - JoinPointMatch jp2 = sMatch2.matchesJoinPoint(new B(), new B(), new Object[] {new A(),new A()}); - assertFalse("does not match",jp2.matches()); - } - - public void testAtArgsWithBinding() { - PointcutParameter p1 = parser.createPointcutParameter("a",MyAnnotation.class); - PointcutParameter p2 = parser.createPointcutParameter("b", MyAnnotation.class); - PointcutExpression atArgs = parser.parsePointcutExpression("@args(..,a)",A.class,new PointcutParameter[] {p1}); - ShadowMatch sMatch2 = atArgs.matchesMethodExecution(c); - assertTrue("maybe matches C",sMatch2.maybeMatches()); - JoinPointMatch jp2 = sMatch2.matchesJoinPoint(new B(), new B(), new Object[]{new A(),new B()}); - assertTrue("matches",jp2.matches()); - assertEquals(1,jp2.getParameterBindings().length); - MyAnnotation bAnnotation = B.class.getAnnotation(MyAnnotation.class); - assertEquals("annotation on B",bAnnotation,jp2.getParameterBindings()[0].getBinding()); - - atArgs = parser.parsePointcutExpression("@args(a,b)",A.class,new PointcutParameter[] {p1,p2}); - sMatch2 = atArgs.matchesMethodExecution(c); - assertTrue("maybe matches C",sMatch2.maybeMatches()); - jp2 = sMatch2.matchesJoinPoint(new B(), new B(), new Object[] {new B(),new B()}); - assertTrue("matches",jp2.matches()); - assertEquals(2,jp2.getParameterBindings().length); - assertEquals("annotation on B",bAnnotation,jp2.getParameterBindings()[0].getBinding()); - assertEquals("annotation on B",bAnnotation,jp2.getParameterBindings()[1].getBinding()); - } - - public void testAtWithin() { - PointcutExpression atWithin = parser.parsePointcutExpression("@within(org.aspectj.weaver.tools.Java15PointcutExpressionTest.MyAnnotation)"); - ShadowMatch sMatch1 = atWithin.matchesMethodExecution(a); - ShadowMatch sMatch2 = atWithin.matchesMethodExecution(b); - assertTrue("does not match a",sMatch1.neverMatches()); - assertTrue("matches b",sMatch2.alwaysMatches()); - } - - public void testAtWithinWithBinding() { - PointcutParameter p1 = parser.createPointcutParameter("x",MyAnnotation.class); - PointcutExpression atWithin = parser.parsePointcutExpression("@within(x)",B.class,new PointcutParameter[] {p1}); - ShadowMatch sMatch1 = atWithin.matchesMethodExecution(a); - ShadowMatch sMatch2 = atWithin.matchesMethodExecution(b); - assertTrue("does not match a",sMatch1.neverMatches()); - assertTrue("matches b",sMatch2.alwaysMatches()); - JoinPointMatch jpm = sMatch2.matchesJoinPoint(new B(), new B(), new Object[0]); - assertTrue(jpm.matches()); - assertEquals(1,jpm.getParameterBindings().length); - MyAnnotation bAnnotation = B.class.getAnnotation(MyAnnotation.class); - assertEquals("annotation on B",bAnnotation,jpm.getParameterBindings()[0].getBinding()); - } - - public void testAtWithinCode() { - PointcutExpression atWithinCode = parser.parsePointcutExpression("@withincode(org.aspectj.weaver.tools.Java15PointcutExpressionTest.MyAnnotation)"); - ShadowMatch sMatch1 = atWithinCode.matchesMethodCall(a,b); - ShadowMatch sMatch2 = atWithinCode.matchesMethodCall(a,a); - assertTrue("does not match from b",sMatch1.neverMatches()); - assertTrue("matches from a",sMatch2.alwaysMatches()); - } - - public void testAtWithinCodeWithBinding() { - PointcutParameter p1 = parser.createPointcutParameter("x",MyAnnotation.class); - PointcutExpression atWithinCode = parser.parsePointcutExpression("@withincode(x)",A.class,new PointcutParameter[] {p1}); - ShadowMatch sMatch2 = atWithinCode.matchesMethodCall(a,a); - assertTrue("matches from a",sMatch2.alwaysMatches()); - JoinPointMatch jpm = sMatch2.matchesJoinPoint(new A(), new A(), new Object[0]); - assertEquals(1,jpm.getParameterBindings().length); - MyAnnotation annOna = a.getAnnotation(MyAnnotation.class); - assertEquals("MyAnnotation on a",annOna,jpm.getParameterBindings()[0].getBinding()); - } - - public void testAtAnnotation() { - PointcutExpression atAnnotation = parser.parsePointcutExpression("@annotation(org.aspectj.weaver.tools.Java15PointcutExpressionTest.MyAnnotation)"); - ShadowMatch sMatch1 = atAnnotation.matchesMethodCall(b,a); - ShadowMatch sMatch2 = atAnnotation.matchesMethodCall(a,a); - assertTrue("does not match call to b",sMatch1.neverMatches()); - assertTrue("matches call to a",sMatch2.alwaysMatches()); - } - - public void testAtAnnotationWithBinding() { - PointcutParameter p1 = parser.createPointcutParameter("x",MyAnnotation.class); - PointcutExpression atAnnotation = parser.parsePointcutExpression("@annotation(x)",A.class,new PointcutParameter[] {p1}); - ShadowMatch sMatch2 = atAnnotation.matchesMethodCall(a,a); - assertTrue("matches call to a",sMatch2.alwaysMatches()); - JoinPointMatch jpm = sMatch2.matchesJoinPoint(new A(), new A(), new Object[0]); - assertTrue(jpm.matches()); - assertEquals(1,jpm.getParameterBindings().length); - MyAnnotation annOna = a.getAnnotation(MyAnnotation.class); - assertEquals("MyAnnotation on a",annOna,jpm.getParameterBindings()[0].getBinding()); - } - - public void testReferencePointcutNoParams() { - PointcutExpression pc = parser.parsePointcutExpression("foo()",C.class,new PointcutParameter[0]); - ShadowMatch sMatch1 = pc.matchesMethodCall(a,b); - ShadowMatch sMatch2 = pc.matchesMethodExecution(a); - assertTrue("no match on call",sMatch1.neverMatches()); - assertTrue("match on execution",sMatch2.alwaysMatches()); - - pc = parser.parsePointcutExpression("org.aspectj.weaver.tools.Java15PointcutExpressionTest.C.foo()"); - sMatch1 = pc.matchesMethodCall(a,b); - sMatch2 = pc.matchesMethodExecution(a); - assertTrue("no match on call",sMatch1.neverMatches()); - assertTrue("match on execution",sMatch2.alwaysMatches()); - } - - public void testReferencePointcutParams() { - PointcutParameter p1 = parser.createPointcutParameter("x",A.class); - PointcutExpression pc = parser.parsePointcutExpression("goo(x)",C.class,new PointcutParameter[] {p1}); - - ShadowMatch sMatch1 = pc.matchesMethodCall(a,b); - ShadowMatch sMatch2 = pc.matchesMethodExecution(a); - assertTrue("no match on call",sMatch1.neverMatches()); - assertTrue("match on execution",sMatch2.maybeMatches()); - A anA = new A(); - JoinPointMatch jpm = sMatch2.matchesJoinPoint(anA, new A(), new Object[0]); - assertTrue(jpm.matches()); - assertEquals("should be bound to anA",anA,jpm.getParameterBindings()[0].getBinding()); - - } - - public void testExecutionWithClassFileRetentionAnnotation() { - PointcutExpression pc1 = parser.parsePointcutExpression("execution(@org.aspectj.weaver.tools.Java15PointcutExpressionTest.MyAnnotation * *(..))"); - PointcutExpression pc2 = parser.parsePointcutExpression("execution(@org.aspectj.weaver.tools.Java15PointcutExpressionTest.MyClassFileRetentionAnnotation * *(..))"); - ShadowMatch sMatch = pc1.matchesMethodExecution(a); - assertTrue("matches",sMatch.alwaysMatches()); - sMatch = pc2.matchesMethodExecution(a); - assertTrue("no match",sMatch.neverMatches()); - sMatch = pc1.matchesMethodExecution(b); - assertTrue("no match",sMatch.neverMatches()); - sMatch = pc2.matchesMethodExecution(b); - assertTrue("matches",sMatch.alwaysMatches()); - } - - public void testGenericMethodSignatures() throws Exception{ - PointcutExpression ex = parser.parsePointcutExpression("execution(* set*(java.util.List))"); - Method m = TestBean.class.getMethod("setFriends",List.class); - ShadowMatch sm = ex.matchesMethodExecution(m); - assertTrue("should match",sm.alwaysMatches()); - } - - public void testAnnotationInExecution() throws Exception { - parser.parsePointcutExpression("execution(@(org.springframework..*) * *(..))"); - } - - public void testVarArgsMatching() throws Exception { - PointcutExpression ex = parser.parsePointcutExpression("execution(* *(String...))"); - Method usesVarArgs = D.class.getMethod("varArgs",String[].class); - Method noVarArgs = D.class.getMethod("nonVarArgs", String[].class); - ShadowMatch sm1 = ex.matchesMethodExecution(usesVarArgs); - assertTrue("should match",sm1.alwaysMatches()); - ShadowMatch sm2 = ex.matchesMethodExecution(noVarArgs); - assertFalse("should not match",sm2.alwaysMatches()); - } - - public void testJavaLangMatching() throws Exception { - PointcutExpression ex = parser.parsePointcutExpression("@within(java.lang.Deprecated)"); - Method foo = GoldenOldie.class.getMethod("foo"); - ShadowMatch sm1 = ex.matchesMethodExecution(foo); - assertTrue("should match",sm1.alwaysMatches()); - } - - public void testReferencePCsInSameType() throws Exception { - PointcutExpression ex = parser.parsePointcutExpression("org.aspectj.weaver.tools.Java15PointcutExpressionTest.NamedPointcutResolution.c()",NamedPointcutResolution.class,new PointcutParameter[0]); - ShadowMatch sm = ex.matchesMethodExecution(a); - assertTrue("should match",sm.alwaysMatches()); - sm = ex.matchesMethodExecution(b); - assertTrue("does not match",sm.neverMatches()); - } - - public void testReferencePCsInOtherType() throws Exception { - PointcutExpression ex = parser.parsePointcutExpression("org.aspectj.weaver.tools.Java15PointcutExpressionTest.ExternalReferrer.d()",ExternalReferrer.class,new PointcutParameter[0]); - ShadowMatch sm = ex.matchesMethodExecution(a); - assertTrue("should match",sm.alwaysMatches()); - sm = ex.matchesMethodExecution(b); - assertTrue("does not match",sm.neverMatches()); - } - - public void testArrayTypeInArgs() throws Exception { - PointcutParameter[] params = new PointcutParameter[3]; - params[0] = parser.createPointcutParameter("d", Date.class); - params[1] = parser.createPointcutParameter("s", String.class); - params[2] = parser.createPointcutParameter("ss", String[].class); - parser.parsePointcutExpression("org.aspectj.weaver.tools.Java15PointcutExpressionTest.UsesArrays.pc(d,s,ss)",UsesArrays.class,params); - } - - protected void setUp() throws Exception { - super.setUp(); - parser = PointcutParser.getPointcutParserSupportingAllPrimitivesAndUsingSpecifiedClassloaderForResolution(this.getClass().getClassLoader()); - a = A.class.getMethod("a"); - b = B.class.getMethod("b"); - c = B.class.getMethod("c",new Class[] {A.class,B.class}); - d = B.class.getMethod("d",new Class[] {A.class,A.class}); - } - - @Retention(RetentionPolicy.RUNTIME) - private @interface MyAnnotation {} - - private @interface MyClassFileRetentionAnnotation {} - - private static class A { - @MyAnnotation public void a() {} - } - - @MyAnnotation - private static class B { - @MyClassFileRetentionAnnotation public void b() {} - public void c(A anA, B aB) {} - - public void d(A anA, A anotherA) {} - } - - private static class C { - - @Pointcut("execution(* *(..))") - public void foo() {} - - @Pointcut(value="execution(* *(..)) && this(x)", argNames="x") - public void goo(A x) {} - } - - private static class D { - - public void nonVarArgs(String[] strings) {}; - - public void varArgs(String... strings) {}; - - } - - static class TestBean { - public void setFriends(List friends) {} - } - - @Deprecated - static class GoldenOldie { - public void foo() {} - } - - private static class NamedPointcutResolution { - - @Pointcut("execution(* *(..))") - public void a() {} - - @Pointcut("this(org.aspectj.weaver.tools.Java15PointcutExpressionTest.A)") - public void b() {} - - @Pointcut("a() && b()") - public void c() {} - } - - private static class ExternalReferrer { - - @Pointcut("org.aspectj.weaver.tools.Java15PointcutExpressionTest.NamedPointcutResolution.a() && " + - "org.aspectj.weaver.tools.Java15PointcutExpressionTest.NamedPointcutResolution.b())") - public void d() {} - - } - - private static class UsesArrays { - - @Pointcut("execution(* *(..)) && args(d,s,ss)") - public void pc(Date d, String s, String[] ss) {} - - } -} - - diff --git a/weaver5/java5-testsrc/test/A.java b/weaver5/java5-testsrc/test/A.java deleted file mode 100644 index 12959cd51..000000000 --- a/weaver5/java5-testsrc/test/A.java +++ /dev/null @@ -1,27 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2008 Contributors - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors - * Andy Clement - * ******************************************************************/ -package test; - -public class A { - public void a(String s) {} - public void b(@A1 String s) {} - public void c(@A1 @A2 String s) {} - public void d(@A1 String s,@A2 String t) {} - - public void e(A1AnnotatedType s) {} - public void f(A2AnnotatedType s) {} - public void g(@A2 A1AnnotatedType s) {} - public void h(@A1 A1AnnotatedType s) {} - public void i(A1AnnotatedType s,@A2 String t) {} - public void j(@A1 @A2 String s) {} - -} diff --git a/weaver5/java5-testsrc/test/A1.java b/weaver5/java5-testsrc/test/A1.java deleted file mode 100644 index 616708345..000000000 --- a/weaver5/java5-testsrc/test/A1.java +++ /dev/null @@ -1,20 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2008 Contributors - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors - * Andy Clement - * ******************************************************************/ -package test; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -@Retention(RetentionPolicy.RUNTIME) -public @interface A1 { - -} diff --git a/weaver5/java5-testsrc/test/A1AnnotatedType.java b/weaver5/java5-testsrc/test/A1AnnotatedType.java deleted file mode 100644 index e40addbf5..000000000 --- a/weaver5/java5-testsrc/test/A1AnnotatedType.java +++ /dev/null @@ -1,17 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2008 Contributors - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors - * Andy Clement - * ******************************************************************/ -package test; - -@A1 -public class A1AnnotatedType { - -} diff --git a/weaver5/java5-testsrc/test/A2.java b/weaver5/java5-testsrc/test/A2.java deleted file mode 100644 index 48749a3d4..000000000 --- a/weaver5/java5-testsrc/test/A2.java +++ /dev/null @@ -1,20 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2008 Contributors - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors - * Andy Clement - * ******************************************************************/ -package test; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -@Retention(RetentionPolicy.RUNTIME) -public @interface A2 { - -} diff --git a/weaver5/java5-testsrc/test/A2AnnotatedType.java b/weaver5/java5-testsrc/test/A2AnnotatedType.java deleted file mode 100644 index 0fa3b5c8a..000000000 --- a/weaver5/java5-testsrc/test/A2AnnotatedType.java +++ /dev/null @@ -1,17 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2008 Contributors - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors - * Andy Clement - * ******************************************************************/ -package test; - -@A2 -public class A2AnnotatedType { - -} diff --git a/weaver5/java5-testsrc/test/A3.java b/weaver5/java5-testsrc/test/A3.java deleted file mode 100644 index ab54388ae..000000000 --- a/weaver5/java5-testsrc/test/A3.java +++ /dev/null @@ -1,19 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2008 Contributors - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors - * Andy Clement - * ******************************************************************/ -package test; - -import java.lang.annotation.*; - -@Retention(RetentionPolicy.RUNTIME) -public @interface A3 { - Color value() default Color.RED; -} diff --git a/weaver5/java5-testsrc/test/AnnoValues.java b/weaver5/java5-testsrc/test/AnnoValues.java deleted file mode 100644 index 08301d1a0..000000000 --- a/weaver5/java5-testsrc/test/AnnoValues.java +++ /dev/null @@ -1,20 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2008 Contributors - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors - * Andy Clement - * ******************************************************************/ -package test; - -public class AnnoValues { - public void none() {} - @A3 public void defaultMethod() {} - @A3(Color.GREEN) public void greenMethod() {} - @A3(Color.RED) public void redMethod() {} - @A3(Color.BLUE) public void blueMethod() {} -} diff --git a/weaver5/java5-testsrc/test/Color.java b/weaver5/java5-testsrc/test/Color.java deleted file mode 100644 index dea2593ac..000000000 --- a/weaver5/java5-testsrc/test/Color.java +++ /dev/null @@ -1,14 +0,0 @@ -package test; -/* ******************************************************************* - * Copyright (c) 2008 Contributors - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors - * Andy Clement - * ******************************************************************/ - -public enum Color { RED, GREEN, BLUE } \ No newline at end of file diff --git a/weaver5/testdata/logging.properties b/weaver5/testdata/logging.properties deleted file mode 100644 index b65bfeaa5..000000000 --- a/weaver5/testdata/logging.properties +++ /dev/null @@ -1,60 +0,0 @@ -############################################################ -# Default Logging Configuration File -# -# You can use a different file by specifying a filename -# with the java.util.logging.config.file system property. -# For example java -Djava.util.logging.config.file=myfile -############################################################ - -############################################################ -# Global properties -############################################################ - -# "handlers" specifies a comma separated list of log Handler -# classes. These handlers will be installed during VM startup. -# Note that these classes must be on the system classpath. -# By default we only configure a ConsoleHandler, which will only -# show messages at the INFO and above levels. -#handlers= java.util.logging.ConsoleHandler - -# To also add the FileHandler, use the following line instead. -#handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler -handlers= java.util.logging.FileHandler - -# Default global logging level. -# This specifies which kinds of events are logged across -# all loggers. For any given facility this global level -# can be overriden by a facility specific level -# Note that the ConsoleHandler also has a separate level -# setting to limit messages printed to the console. -.level= INFO - -############################################################ -# Handler specific properties. -# Describes specific configuration info for Handlers. -############################################################ - -# default file output is in user's home directory. -java.util.logging.FileHandler.pattern = %h/java%u.log -#java.util.logging.FileHandler.limit = 50000 -java.util.logging.FileHandler.count = 1 -#java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter -java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter -java.util.logging.FileHandler.level = FINER - -# Limit the message that are printed on the console to INFO and above. -java.util.logging.ConsoleHandler.level = FINER -java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter - - -############################################################ -# Facility specific properties. -# Provides extra control for each logger. -############################################################ - -# For example, set the com.xyz.foo logger to only log SEVERE -# messages: -#com.xyz.foo.level = SEVERE -org.aspectj.weaver.level = FINER -org.aspectj.weaver.loadtime.level = FINER -org.aspectj.weaver.weaver.level = FINER diff --git a/weaver5/testsrc/org/aspectj/weaver/Weaver5ModuleTests.java b/weaver5/testsrc/org/aspectj/weaver/Weaver5ModuleTests.java deleted file mode 100644 index 96bc6d007..000000000 --- a/weaver5/testsrc/org/aspectj/weaver/Weaver5ModuleTests.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.aspectj.weaver; -/******************************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: (See CVS logs) - * - *******************************************************************************/ - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -import org.aspectj.testing.util.TestUtil; - -/** - */ -public class Weaver5ModuleTests extends TestCase { - - public static Test suite() { - TestSuite suite = new TestSuite(Weaver5ModuleTests.class.getName()); - if (TestUtil.is15VMOrGreater()) { - TestUtil.loadTestsReflectively(suite, "org.aspectj.weaver.AllWeaver5Tests", false); - } else { - suite.addTest(TestUtil.testNamed("all tests require 1.5")); - } - return suite; - } - public static void main(String[] args) { - junit.textui.TestRunner.main(new String[] {Weaver5ModuleTests.class.getName()}); - } - -} -- 2.39.5