You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by em...@apache.org on 2026/03/05 17:01:50 UTC
(groovy) branch GROOVY-6526 updated (62d0f8bda9 -> f8071cba56)
This is an automated email from the ASF dual-hosted git repository.
emilles pushed a change to branch GROOVY-6526
in repository https://gitbox.apache.org/repos/asf/groovy.git
omit 62d0f8bda9 GROOVY-6526: compute allowed targets lazily
add eb5d69496b GROOVY-10307 (fix broken benchmark)
add 36ad881846 GROOVY-11831, GROOVY-11838: fix test case
add 38c0edef95 remove deprecated references
add b907685674 remove deprecated references
add 90e7ea2d42 minor items
add 5afd9b9a91 junit jupiter
add 8a40250d99 junit jupiter
add 0b6a5fd2f2 junit jupiter
add 9ad4468d78 junit jupiter
add 61fff4f445 junit jupiter
add b1b875a79f junit jupiter
add 2fc4123bba GROOVY-10307: add targeted JMH benchmarks for SwitchPoint invalidation regression
add a6a83ab22f fix: address Copilot review feedback on benchmark code
add 2ac5b7579f GROOVY-11867: Bump checkstyle to 12.3.1 (build dependency)
add 3ec2fe65db junit jupiter
add 8a042bf3bf remove `implements Opcodes` from `TestSupport`
add 396e6cebdb bump dnsjava to 3.6.4 (perf test compilation dependency)
add 65c4de3269 GROOVY-11868: Bump gradle to 9.4.0 (build dependency)
add 7d8349c4b7 GROOVY-11869: Bump junit5 jupiter/platform to 5.14.3/1.14.3
new 88e170b468 GROOVY-6526: compute allowed targets lazily
new b8d64b4727 GROOVY-6526: compute retention policy lazily
new f8071cba56 minor items
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (62d0f8bda9)
\
N -- N -- N refs/heads/GROOVY-6526 (f8071cba56)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../src/main/groovy/org.apache.groovy-base.gradle | 2 +-
.../groovy/gradle/PerformanceTestsExtension.groovy | 2 +-
build.gradle | 1 +
gradle.properties | 4 +-
gradle/verification-metadata.xml | 90 ++--
gradle/wrapper/gradle-wrapper.jar | Bin 46175 -> 43583 bytes
gradle/wrapper/gradle-wrapper.properties | 2 +-
gradlew | 12 +-
gradlew.bat | 3 +-
.../org/codehaus/groovy/ast/AnnotationNode.java | 94 +++--
.../groovy/ast/ClassCodeVisitorSupport.java | 5 +-
.../groovy/classgen/AsmClassGenerator.java | 10 +-
.../codehaus/groovy/classgen/ExtendedVerifier.java | 6 +-
.../org/codehaus/groovy/vmplugin/VMPlugin.java | 14 +-
.../org/codehaus/groovy/vmplugin/v8/Java8.java | 50 +--
src/spec/test/BaseScriptSpecTest.groovy | 11 +-
src/spec/test/ClassDesignASTTransformsTest.groovy | 4 +-
src/spec/test/ClassTest.groovy | 25 ++
src/spec/test/CloningASTTransformsTest.groovy | 4 +-
src/spec/test/ClosuresSpecTest.groovy | 12 +-
.../test/CodeGenerationASTTransformsTest.groovy | 3 +-
.../CompilerDirectivesASTTransformsTest.groovy | 4 +-
src/spec/test/CustomizersTest.groovy | 2 +-
.../DeclarativeConcurrencyASTTransformsTest.groovy | 4 +-
src/spec/test/DelegatesToSpecTest.groovy | 4 +-
src/spec/test/DesignPatternsTest.groovy | 147 ++++---
src/spec/test/DifferencesFromJavaTest.groovy | 4 +-
src/spec/test/ExtensionModuleSpecTest.groovy | 12 +-
src/spec/test/IntegrationTest.groovy | 15 +-
.../test/LogImprovementsASTTransformsTest.groovy | 4 +-
src/spec/test/OperatorsTest.groovy | 1 +
src/spec/test/PrimitiveTest.groovy | 11 +-
src/spec/test/RecordSpecificationTest.groovy | 10 +-
.../test/SaferScriptingASTTransformsTest.groovy | 6 +-
src/spec/test/ScriptsAndClassesSpecTest.groovy | 10 +-
src/spec/test/SealedSpecificationTest.groovy | 11 +-
src/spec/test/StyleGuideTest.groovy | 6 +-
src/spec/test/SwingASTTransformsTest.groovy | 5 +-
src/spec/test/SyntaxTest.groovy | 41 +-
src/spec/test/TestingASTTransformsTest.groovy | 3 +-
src/spec/test/TraitsSpecificationTest.groovy | 10 +-
src/spec/test/asciidoctor/Utils.groovy | 7 +-
src/spec/test/builder/BuilderSpecTest.groovy | 3 +-
src/spec/test/gdk/ConfigSlurperTest.groovy | 2 +-
src/spec/test/gdk/ExpandoTest.groovy | 3 +-
src/spec/test/gdk/ObservableTest.groovy | 3 +-
.../test/gdk/WorkingWithCollectionsTest.groovy | 2 +-
src/spec/test/gdk/WorkingWithIOSpecTest.groovy | 2 +-
.../metaprogramming/ASTMatcherFilteringTest.groovy | 3 +-
.../metaprogramming/ASTMatcherTestingTest.groovy | 4 +-
.../test/metaprogramming/ASTXFormSpecTest.groovy | 3 +-
.../metaprogramming/ExpandoMetaClassTest.groovy | 6 +-
.../test/metaprogramming/GroovyObjectTest.groovy | 2 +-
.../test/metaprogramming/InterceptableTest.groovy | 3 +-
.../InterceptionThroughMetaClassTest.groovy | 2 +-
.../test/metaprogramming/MacroClassTest.groovy | 3 +-
.../metaprogramming/MacroExpressionTest.groovy | 3 +-
.../test/metaprogramming/MacroStatementTest.groovy | 4 +-
.../MacroVariableSubstitutionTest.groovy | 4 +-
.../MethodPropertyMissingTest.groovy | 4 +-
...taticPropertyMissingAndMethodMissingTest.groovy | 3 +-
src/spec/test/objectorientation/MethodsTest.groovy | 3 +-
src/spec/test/semantics/GPathTest.groovy | 3 +-
src/spec/test/semantics/OptionalityTest.groovy | 9 +-
src/spec/test/semantics/TheGroovyTruthTest.groovy | 3 +-
src/spec/test/support/StaticStringExtension.groovy | 2 +-
src/spec/test/testingguide/GDKMethodTests.groovy | 3 +-
.../testingguide/GroovyTestCaseExampleTests.groovy | 3 +-
.../test/testingguide/JUnit4ExampleTests.groovy | 2 +-
.../test/testingguide/MockingExampleTests.groovy | 12 +-
src/spec/test/typing/OptionalTypingTest.groovy | 3 +-
src/spec/test/typing/PrecompiledJavaExtension.java | 5 +-
src/spec/test/typing/Robot.groovy | 2 +-
src/spec/test/typing/TypeCheckingHintsTest.groovy | 14 +-
src/spec/test/typing/TypeCheckingJavaTest.java | 4 +-
src/spec/test/typing/TypeCheckingTest.groovy | 27 +-
src/test/groovy/NoPackageTest.groovy | 2 +
.../groovy/bugs/AmbiguousListOrMethodTest.groovy | 12 +-
src/test/groovy/bugs/ArrayMethodCallBug.groovy | 4 +-
src/test/groovy/bugs/AsBoolBug.groovy | 3 +-
.../bugs/AssignmentInsideExpressionBug.groovy | 5 +-
.../groovy/bugs/AttributeSetExpressionBug.groovy | 16 +-
.../groovy/bugs/AutoboxingOfComparisonsBug.groovy | 2 +-
.../bugs/BadLineNumberOnExceptionBugTest.groovy | 3 +-
src/test/groovy/bugs/BadScriptNameBug.groovy | 3 +-
src/test/groovy/bugs/BenchmarkBug.groovy | 5 +-
src/test/groovy/bugs/BlockAsClosureBug.groovy | 3 +-
src/test/groovy/bugs/BooleanBug.groovy | 14 +-
src/test/groovy/bugs/ByteIndexBug.groovy | 2 +-
src/test/groovy/bugs/Bytecode2Bug.groovy | 5 +-
src/test/groovy/bugs/Bytecode3Bug.groovy | 5 +-
src/test/groovy/bugs/Bytecode4Bug.groovy | 5 +-
src/test/groovy/bugs/Bytecode5Bug.groovy | 5 +-
src/test/groovy/bugs/Bytecode6Bug.groovy | 5 +-
src/test/groovy/bugs/Bytecode7Bug.groovy | 5 +-
src/test/groovy/bugs/BytecodeBug.groovy | 5 +-
.../bugs/CallingClosuresWithClosuresBug.groovy | 5 +-
.../groovy/bugs/CastWhenUsingClosuresBug.groovy | 5 +-
src/test/groovy/bugs/ChristofsPropertyBug.groovy | 3 +-
.../groovy/bugs/ClassGeneratorFixesTest.groovy | 15 +-
src/test/groovy/bugs/ClassInNamedParamsBug.groovy | 3 +-
src/test/groovy/bugs/ClassInScriptBug.java | 6 +-
src/test/groovy/bugs/ClosureInClosureBug.groovy | 3 +-
.../groovy/bugs/ClosureTypedVariableBug.groovy | 3 +-
src/test/groovy/bugs/ClosureVariableBug.groovy | 5 +-
.../bugs/ClosureWithBitwiseDefaultParamTest.groovy | 2 +-
.../bugs/ClosureWithStaticVariablesBug.groovy | 11 +-
src/test/groovy/bugs/ClosuresInScriptBug.java | 6 +-
src/test/groovy/bugs/ConstructorBug.groovy | 4 +-
src/test/groovy/bugs/ConstructorThisCallBug.groovy | 8 +-
src/test/groovy/bugs/CustomMetaClassTest.groovy | 21 +-
src/test/groovy/bugs/DefVariableBug.groovy | 3 +-
.../groovy/bugs/DoubleSizeParametersBug.groovy | 11 +-
src/test/groovy/bugs/ForLoopBug.groovy | 4 +-
src/test/groovy/bugs/FullyQualifiedClassBug.groovy | 6 +-
.../bugs/FullyQualifiedMethodReturnTypeBug.groovy | 6 +-
.../bugs/FullyQualifiedVariableTypeBug.groovy | 6 +-
src/test/groovy/bugs/GetterBug.groovy | 9 +-
src/test/groovy/bugs/Groovy10143.groovy | 1 +
.../{Groovy1018_Bug.groovy => Groovy1018.groovy} | 19 +-
src/test/groovy/bugs/Groovy10199.groovy | 1 +
src/test/groovy/bugs/Groovy10236.groovy | 2 -
src/test/groovy/bugs/Groovy10281.groovy | 3 +-
src/test/groovy/bugs/Groovy10303.groovy | 1 +
src/test/groovy/bugs/Groovy10381.groovy | 1 +
src/test/groovy/bugs/Groovy10461.groovy | 1 +
.../{Groovy1059_Bug.groovy => Groovy1059.groovy} | 24 +-
src/test/groovy/bugs/Groovy10659.groovy | 1 +
src/test/groovy/bugs/Groovy10676.groovy | 1 +
src/test/groovy/bugs/Groovy10700.groovy | 1 +
.../{Groovy1081_Bug.groovy => Groovy1081.groovy} | 5 +-
src/test/groovy/bugs/Groovy11062.groovy | 2 -
src/test/groovy/bugs/Groovy11182.groovy | 1 +
src/test/groovy/bugs/Groovy11265.groovy | 1 +
src/test/groovy/bugs/Groovy11272.groovy | 1 +
src/test/groovy/bugs/Groovy11293.groovy | 1 +
src/test/groovy/bugs/Groovy11568.groovy | 1 +
src/test/groovy/bugs/Groovy11613.groovy | 1 +
.../{Groovy1407_Bug.groovy => Groovy1407.groovy} | 2 +-
.../{Groovy1462_Bug.groovy => Groovy1462.groovy} | 25 +-
src/test/groovy/bugs/Groovy1567.java | 4 +-
src/test/groovy/bugs/Groovy1593.groovy | 22 +-
.../{Bytecode7Bug.groovy => Groovy1617.groovy} | 32 +-
src/test/groovy/bugs/Groovy1617_Bug.groovy | 41 --
.../groovy/bugs/Groovy1706.groovy} | 35 +-
src/test/groovy/bugs/Groovy1706_Bug.groovy | 46 --
src/test/groovy/bugs/Groovy3596Bug.groovy | 5 +-
src/test/groovy/bugs/Groovy3721Bug.groovy | 5 +-
src/test/groovy/bugs/Groovy3768Bug.groovy | 5 +-
src/test/groovy/bugs/Groovy3817Bug.groovy | 5 +-
src/test/groovy/bugs/Groovy3857Bug.groovy | 5 +-
src/test/groovy/bugs/Groovy3989Bug.groovy | 5 +-
src/test/groovy/bugs/Groovy4025Bug.groovy | 11 +-
src/test/groovy/bugs/Groovy4043Bug.groovy | 5 +-
src/test/groovy/bugs/Groovy4081Bug.groovy | 7 +-
src/test/groovy/bugs/Groovy4151Bug.groovy | 9 +-
src/test/groovy/bugs/Groovy4169Bug.groovy | 5 +-
src/test/groovy/bugs/Groovy4190Bug.groovy | 6 +-
src/test/groovy/bugs/Groovy4325Bug.groovy | 5 +-
src/test/groovy/bugs/Groovy4356Bug.groovy | 11 +-
src/test/groovy/bugs/Groovy4614Bug.groovy | 5 +-
src/test/groovy/bugs/Groovy6271Bug.groovy | 5 +-
src/test/groovy/bugs/Groovy6786Bug.groovy | 7 +-
src/test/groovy/bugs/Groovy6792Bug.groovy | 23 +-
src/test/groovy/bugs/Groovy6804Bug.groovy | 22 +-
src/test/groovy/bugs/Groovy7922Bug.groovy | 4 +-
src/test/groovy/bugs/Groovy7925Bug.groovy | 5 +-
src/test/groovy/bugs/Groovy8066Bug.groovy | 5 +-
src/test/groovy/bugs/Groovy8342Bug.groovy | 5 +-
src/test/groovy/bugs/Groovy8405Bug.groovy | 7 +-
src/test/groovy/bugs/Groovy8549Bug.groovy | 5 +-
src/test/groovy/bugs/Groovy8595Bug.groovy | 6 +-
src/test/groovy/bugs/Groovy8797Bug.groovy | 5 +-
src/test/groovy/bugs/IanMaceysBug.java | 20 +-
.../groovy/bugs/IterateOverCustomTypeBug.groovy | 4 +-
src/test/groovy/bugs/NestedClosure2Bug.groovy | 15 +-
src/test/groovy/bugs/ScriptBug.java | 6 +-
.../bugs/SubscriptOnPrimitiveTypeArrayBug.groovy | 8 +-
.../groovy/bugs/SubscriptOnStringArrayBug.groovy | 15 +-
src/test/groovy/bugs/VariableScopingBug.groovy | 47 ++-
.../closures/AnnotationClosureTest.groovy | 18 +-
.../groovy/gls/ch08/s04/FormalParameterTest.groovy | 8 +-
.../classes/methods/RepetitiveMethodTest.groovy | 6 +-
src/test/groovy/gls/enums/EnumTest.groovy | 54 ++-
.../invocation/GroovyObjectInheritanceTest.groovy | 11 +-
.../gls/invocation/MethodDeclarationTest.groovy | 7 +-
.../gls/invocation/MethodSelectionTest.groovy | 24 +-
.../invocation/StaticMethodInvocationTest.groovy | 48 ++-
.../gls/property/MetaClassOverridingTest.groovy | 9 +-
.../gls/scope/BlockScopeVisibilityTest.groovy | 14 +-
.../gls/scope/ClassVariableHidingTest.groovy | 8 +-
src/test/groovy/gls/scope/FinalAccessTest.groovy | 8 +-
.../MultipleDefinitionOfSameVariableTest.groovy | 20 +-
src/test/groovy/gls/scope/NameResolvingTest.groovy | 13 +-
src/test/groovy/gls/scope/StaticScopeTest.groovy | 21 +-
.../groovy/gls/sizelimits/StringSizeTest.groovy | 11 +-
.../groovy/gls/statements/DeclarationTest.groovy | 17 +-
src/test/groovy/gls/statements/ReturnTest.groovy | 12 +-
src/test/groovy/gls/syntax/AssertTest.groovy | 22 +-
.../groovy/gls/syntax/BinaryLiteralTest.groovy | 6 +-
.../gls/syntax/MethodCallValidationTest.groovy | 8 +-
.../groovy/gls/syntax/NumberLiteralTest.groovy | 11 +-
.../gls/syntax/OldClosureSyntaxRemovalTest.groovy | 6 +-
.../gls/syntax/OldPropertySyntaxRemovalTest.groovy | 6 +-
src/test/groovy/gls/syntax/OldSpreadTest.groovy | 8 +-
src/test/groovy/gls/syntax/ParsingTest.groovy | 8 +-
.../gls/syntax/UnderscoreInNumbersTest.groovy | 76 ++--
.../types/BooleanExpressionConversionTest.groovy | 14 +-
src/test/groovy/gls/types/GroovyCastTest.groovy | 11 +-
.../gls/types/OperationsResultTypeTest.groovy | 5 +-
.../groovy/AbstractClassAndInterfaceTest.groovy | 36 +-
.../groovy/groovy/MethodInBadPositionTest.groovy | 20 +-
src/test/groovy/groovy/ModifiersTest.groovy | 31 +-
.../groovy/SerializableCompatibilityTest.groovy | 7 +-
src/test/groovy/groovy/StaticThisTest.groovy | 14 +-
src/test/groovy/groovy/TryCatchTest.groovy | 14 +-
.../groovy/lang/ScriptIntegerDivideTest.java | 6 +-
src/test/groovy/groovy/lang/ScriptPrintTest.java | 7 +-
src/test/groovy/groovy/lang/ScriptTest.java | 44 +-
.../stc/AnonymousInnerClassSTCTest.groovy | 17 +
.../stc/ArraysAndCollectionsSTCTest.groovy | 87 ++++
.../groovy/groovy/transform/stc/BugsSTCTest.groovy | 80 +++-
.../groovy/transform/stc/CategoriesSTCTest.groovy | 5 +-
.../stc/ClosureParamTypeInferenceSTCTest.groovy | 159 +++++++
.../groovy/transform/stc/ClosuresSTCTest.groovy | 86 ++++
.../groovy/transform/stc/CoercionSTCTest.groovy | 56 +++
.../transform/stc/ConstructorsSTCTest.groovy | 61 ++-
.../stc/CustomErrorCollectorSTCTest.groovy | 17 +-
.../stc/DefaultGroovyMethodsSTCTest.groovy | 34 ++
.../groovy/transform/stc/DelegatesToSTCTest.groovy | 37 ++
.../stc/FieldsAndPropertiesSTCTest.groovy | 116 +++++
.../groovy/transform/stc/GenericsSTCTest.groovy | 393 +++++++++++++++--
.../groovy/transform/stc/Groovy7184Bug.groovy | 9 +-
.../groovy/transform/stc/Groovy7542Bug.groovy | 7 +-
.../groovy/transform/stc/Groovy7774Bug.groovy | 8 +-
.../groovy/transform/stc/Groovy7880Bug.groovy | 5 +-
.../groovy/transform/stc/Groovy7907Bug.groovy | 6 +-
.../groovy/transform/stc/Groovy8246Bug.groovy | 7 +-
.../IOGMClosureParamTypeInferenceSTCTest.groovy | 19 +-
.../groovy/transform/stc/LoopsSTCTest.groovy | 29 ++
.../groovy/transform/stc/MethodCallsSTCTest.groovy | 180 +++++++-
.../groovy/groovy/transform/stc/MiscSTCTest.groovy | 34 +-
.../groovy/transform/stc/RangesSTCTest.groovy | 10 +-
...sourceGMClosureParamTypeInferenceSTCTest.groovy | 31 +-
.../groovy/transform/stc/ReturnsSTCTest.groovy | 23 +
.../groovy/transform/stc/STCAssignmentTest.groovy | 111 +++++
.../transform/stc/STCExtensionMethodsTest.groovy | 13 +
.../transform/stc/STCnAryExpressionTest.groovy | 23 +
.../stc/STCwithTransformationsTest.groovy | 50 ++-
...SocketGMClosureParamTypeInferenceSTCTest.groovy | 7 +
...StringGMClosureParamTypeInferenceSTCTest.groovy | 19 +
.../transform/stc/TernaryOperatorSTCTest.groovy | 32 ++
.../stc/TypeCheckingExtensionsTest.groovy | 61 ++-
.../transform/stc/TypeCheckingModeTest.groovy | 11 +
.../transform/stc/TypeInferenceSTCTest.groovy | 111 ++++-
.../transform/stc/UnaryOperatorSTCTest.groovy | 56 +++
src/test/groovy/groovy/tree/NodePrinterTest.java | 24 +-
src/test/groovy/groovy/util/MiscScriptTest.groovy | 9 +-
.../codehaus/groovy/ast/AnnotationNodeTest.groovy | 36 ++
.../groovy/benchmarks/vm5/b2394/Builder.java | 7 +-
.../codehaus/groovy/benchmarks/vm5/b2394/Main.java | 120 +++---
.../benchmarks/vm5/b2394/ScriptLauncher.java | 31 +-
.../groovy/classgen/ConstructorIssueTest.groovy | 53 ---
.../codehaus/groovy/classgen/ConstructorTest.java | 6 +-
.../org/codehaus/groovy/classgen/ForTest.java | 41 +-
.../org/codehaus/groovy/classgen/GStringTest.java | 27 +-
.../codehaus/groovy/classgen/GetPropertyTest.java | 12 +-
.../groovy/classgen/GroovyClassLoaderTest.java | 20 +-
.../org/codehaus/groovy/classgen/IfElseTest.java | 28 +-
.../org/codehaus/groovy/classgen/MainTest.java | 6 +-
.../org/codehaus/groovy/classgen/MethodTest.java | 28 +-
.../org/codehaus/groovy/classgen/PropertyTest.java | 33 +-
.../org/codehaus/groovy/classgen/RunBugsTest.java | 61 ++-
.../codehaus/groovy/classgen/RunClosureTest.java | 34 +-
.../codehaus/groovy/classgen/RunGroovyTest.java | 21 +-
.../codehaus/groovy/classgen/TupleListTest.java | 36 +-
.../ArraysAndCollectionsStaticCompileTest.groovy | 11 +
.../asm/sc/AssignmentsStaticCompileTest.groovy | 4 +-
.../classgen/asm/sc/BugsStaticCompileTest.groovy | 95 +++++
...osureParamTypeInferenceStaticCompileTest.groovy | 2 +-
.../asm/sc/ClosuresStaticCompileTest.groovy | 7 +-
.../asm/sc/CoercionStaticCompileTests.groovy | 4 +-
.../sc/CompatWithASTXFormStaticCompileTest.groovy | 5 +-
.../classgen/asm/sc/CompileDynamicTest.groovy | 6 +-
.../asm/sc/DelegatesToStaticCompileTest.groovy | 6 +-
.../sc/FieldsAndPropertiesStaticCompileTest.groovy | 40 +-
.../asm/sc/GenericsStaticCompileTest.groovy | 5 +-
.../asm/sc/Groovy7222OptimizationsTest.groovy | 41 +-
...osureParamTypeInferenceStaticCompileTest.groovy | 5 +-
.../classgen/asm/sc/LoopsStaticCompileTest.groovy | 2 +
.../asm/sc/MethodCallsStaticCompilationTest.groovy | 25 +-
.../classgen/asm/sc/MiscStaticCompileTest.groovy | 4 +-
.../asm/sc/MixedModeStaticCompilationTest.groovy | 26 +-
.../sc/NaryExpressionTestStaticCompileTest.groovy | 5 +-
.../classgen/asm/sc/RangesStaticCompileTest.groovy | 19 +-
...osureParamTypeInferenceStaticCompileTest.groovy | 4 +-
.../asm/sc/ReturnsStaticCompileTest.groovy | 2 +-
...osureParamTypeInferenceStaticCompileTest.groovy | 4 +-
.../asm/sc/StaticCompilationTestSupport.groovy | 18 +-
.../sc/StaticCompileCastOptimizationTest.groovy | 100 ++---
.../asm/sc/StaticCompileConstructorsTest.groovy | 8 +-
.../classgen/asm/sc/StaticCompileDGMTest.groovy | 3 +
.../sc/StaticCompileExtensionMethodsTest.groovy | 5 +-
...osureParamTypeInferenceStaticCompileTest.groovy | 4 +-
.../sc/TypeCheckingModeStaticCompileTest.groovy | 4 +
.../asm/sc/UnaryOperatorStaticCompileTest.groovy | 9 +-
.../groovy/classgen/asm/sc/bugs/Groovy11359.groovy | 21 +-
.../groovy/classgen/asm/sc/bugs/Groovy6276.groovy | 3 +
.../classgen/asm/sc/bugs/Groovy6411Bug.groovy | 51 +--
.../classgen/asm/sc/bugs/Groovy6475Bug.groovy | 10 +-
.../classgen/asm/sc/bugs/Groovy6533Bug.groovy | 5 +-
.../classgen/asm/sc/bugs/Groovy6541Bug.groovy | 9 +-
.../classgen/asm/sc/bugs/Groovy6558Bug.groovy | 5 +
.../classgen/asm/sc/bugs/Groovy6564Bug.groovy | 3 +
.../classgen/asm/sc/bugs/Groovy6568Bug.groovy | 4 +-
.../classgen/asm/sc/bugs/Groovy6627Bug.groovy | 9 +-
.../groovy/classgen/asm/sc/bugs/Groovy6650.groovy | 3 +
.../classgen/asm/sc/bugs/Groovy6657Bug.groovy | 6 +-
.../groovy/classgen/asm/sc/bugs/Groovy6671.groovy | 3 +
.../classgen/asm/sc/bugs/Groovy6676Bug.groovy | 8 +-
.../classgen/asm/sc/bugs/Groovy6693Bug.groovy | 5 +-
.../classgen/asm/sc/bugs/Groovy6724Bug.groovy | 6 +-
.../classgen/asm/sc/bugs/Groovy6733Bug.groovy | 7 +-
.../classgen/asm/sc/bugs/Groovy6757Bug.groovy | 9 +-
.../classgen/asm/sc/bugs/Groovy6962Bug.groovy | 5 +-
.../classgen/asm/sc/bugs/Groovy7039Bug.groovy | 14 +-
.../classgen/asm/sc/bugs/Groovy7041Bug.groovy | 9 +-
.../classgen/asm/sc/bugs/Groovy7042Bug.groovy | 6 +-
.../classgen/asm/sc/bugs/Groovy7072Bug.groovy | 15 +-
.../classgen/asm/sc/bugs/Groovy7075Bug.groovy | 9 +-
.../classgen/asm/sc/bugs/Groovy7093Bug.groovy | 11 +-
.../classgen/asm/sc/bugs/Groovy7098Bug.groovy | 11 +-
.../classgen/asm/sc/bugs/Groovy7133Bug.groovy | 19 +-
.../classgen/asm/sc/bugs/Groovy7138Bug.groovy | 8 +-
.../classgen/asm/sc/bugs/Groovy7145Bug.groovy | 13 +-
.../classgen/asm/sc/bugs/Groovy7149Bug.groovy | 11 +-
.../classgen/asm/sc/bugs/Groovy7169Bug.groovy | 12 +-
.../classgen/asm/sc/bugs/Groovy7210Bug.groovy | 9 +-
.../classgen/asm/sc/bugs/Groovy7211Bug.groovy | 5 +-
.../groovy/classgen/asm/sc/bugs/Groovy7276.groovy | 118 +++---
.../classgen/asm/sc/bugs/Groovy7298Bug.groovy | 32 +-
.../groovy/classgen/asm/sc/bugs/Groovy7300.groovy | 5 +
.../classgen/asm/sc/bugs/Groovy7307Bug.groovy | 11 +-
.../classgen/asm/sc/bugs/Groovy7316Bug.groovy | 16 +-
.../classgen/asm/sc/bugs/Groovy7324Bug.groovy | 5 +-
.../classgen/asm/sc/bugs/Groovy7325Bug.groovy | 3 +
.../classgen/asm/sc/bugs/Groovy7327Bug.groovy | 11 +-
.../groovy/classgen/asm/sc/bugs/Groovy7333.groovy | 3 +
.../classgen/asm/sc/bugs/Groovy7343Bug.groovy | 11 +-
.../classgen/asm/sc/bugs/Groovy7355Bug.groovy | 13 +-
.../classgen/asm/sc/bugs/Groovy7356Bug.groovy | 16 +-
.../classgen/asm/sc/bugs/Groovy7357Bug.groovy | 20 +-
.../classgen/asm/sc/bugs/Groovy7358Bug.groovy | 23 +-
.../classgen/asm/sc/bugs/Groovy7361Bug.groovy | 5 +
.../classgen/asm/sc/bugs/Groovy7363Bug.groovy | 5 +-
.../classgen/asm/sc/bugs/Groovy7364Bug.groovy | 20 +-
.../classgen/asm/sc/bugs/Groovy7365Bug.groovy | 5 +-
.../classgen/asm/sc/bugs/Groovy7420Bug.groovy | 5 +-
.../classgen/asm/sc/bugs/Groovy7538Bug.groovy | 7 +-
.../classgen/asm/sc/bugs/Groovy7870Bug.groovy | 9 +-
.../classgen/asm/sc/bugs/Groovy8069Bug.groovy | 7 +-
.../classgen/asm/sc/bugs/Groovy8240Bug.groovy | 7 +-
.../groovy/classgen/asm/sc/bugs/Groovy9892.groovy | 3 +
.../asm/sc/bugs/ReproducibleBytecodeBugs.groovy | 84 ++--
.../runtime/ArrayGroovyMethodsSTCTest.groovy | 42 +-
.../groovy/runtime/StaticPrintlnTest.groovy | 6 +-
.../m12n/ExtensionModuleHelperForTests.groovy | 19 +-
.../groovy/runtime/m12n/ExtensionModuleTest.groovy | 4 +-
.../AutoFinalTransformBlackBoxTest.groovy | 18 +-
.../groovy/transform/SortableTransformTest.groovy | 14 +-
.../groovy/transform/SourceURITransformTest.groovy | 6 +-
src/test/java/groovy/NamedParameterHelper.java | 11 +-
.../concurrentlinkedhashmap/LinkedDequeTest.java | 121 +++---
.../groovy/util/CharSequenceReaderTest.java | 180 ++++----
.../groovy/cli/CliBuilderTestCase.groovy | 26 +-
.../groovy/gls/CompilableTestSupport.groovy | 41 +-
.../groovy/groovy/bugs/TestSupport.java | 14 +-
.../stc/StaticTypeCheckingTestCase.groovy | 49 ++-
.../groovy/groovy/util/HeadlessTestSupport.groovy | 22 +-
src/testFixtures/groovy/groovy/util/XmlAssert.java | 12 +-
.../codehaus/groovy/ast/builder/AstAssert.groovy | 92 ++--
.../org/codehaus/groovy/classgen/TestSupport.java | 181 ++++----
.../src/spec/test/builder/CliBuilderTest.groovy | 9 +-
.../src/spec/test/builder/CliBuilderTest.groovy | 18 +-
.../groovy-jmx/src/spec/test/JmxTest.groovy | 11 +-
.../groovy/macro/matcher/ASTMatcher.groovy | 8 -
.../src/spec/test/servlet/GroovyServletTest.groovy | 5 +-
.../src/spec/test/SwingBuilderTest.groovy | 6 +-
.../groovy/groovy/swing/SwingBuilderTest.groovy | 2 +-
.../src/spec/test/TemplateEnginesTest.groovy | 11 +-
.../src/test/groovy/groovy/xml/DOMTest.groovy | 24 +-
.../groovy/groovy/xml/MarkupWithWriterTest.groovy | 10 +-
.../groovy/xml/NamespaceNodeGPathTest.groovy | 5 +-
.../groovy/groovy/xml/NamespaceNodeTest.groovy | 7 +-
.../src/test/groovy/groovy/xml/SAXTest.groovy | 12 +-
.../src/test/groovy/groovy/xml/TestXmlSupport.java | 12 +-
.../test/groovy/groovy/xml/VerboseDOMTest.groovy | 20 +-
.../groovy/groovy/xml/bugs/MarkupInScriptBug.java | 7 +-
.../src/test/groovy/groovy/xml/bugs/SeansBug.java | 10 +-
.../groovy/groovy/xml/dom/NamespaceDOMTest.groovy | 6 +-
.../perf/grails/CallSiteInvalidationBench.groovy | 224 ++++++++++
.../perf/grails/GrailsLikePatternsBench.groovy | 6 +-
.../groovy/perf/grails/GrailsWorkloadBench.groovy | 468 +++++++++++++++++++++
.../perf/grails/MetaclassVariationBench.groovy | 259 ++++++++++++
versions.properties | 6 +-
405 files changed, 5862 insertions(+), 2358 deletions(-)
rename src/test/groovy/bugs/{Groovy1018_Bug.groovy => Groovy1018.groovy} (75%)
rename src/test/groovy/bugs/{Groovy1059_Bug.groovy => Groovy1059.groovy} (78%)
rename src/test/groovy/bugs/{Groovy1081_Bug.groovy => Groovy1081.groovy} (98%)
rename src/test/groovy/bugs/{Groovy1407_Bug.groovy => Groovy1407.groovy} (98%)
rename src/test/groovy/bugs/{Groovy1462_Bug.groovy => Groovy1462.groovy} (79%)
copy src/test/groovy/bugs/{Bytecode7Bug.groovy => Groovy1617.groovy} (65%)
delete mode 100644 src/test/groovy/bugs/Groovy1617_Bug.groovy
copy src/{spec/test/gdk/ExpandoTest.groovy => test/groovy/bugs/Groovy1706.groovy} (58%)
delete mode 100644 src/test/groovy/bugs/Groovy1706_Bug.groovy
delete mode 100644 src/test/groovy/org/codehaus/groovy/classgen/ConstructorIssueTest.groovy
create mode 100644 subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/grails/CallSiteInvalidationBench.groovy
create mode 100644 subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/grails/GrailsWorkloadBench.groovy
create mode 100644 subprojects/performance/src/jmh/groovy/org/apache/groovy/perf/grails/MetaclassVariationBench.groovy
(groovy) 03/03: minor items
Posted by em...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
emilles pushed a commit to branch GROOVY-6526
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit f8071cba569d7fe7cf8a73ca07e391acaf65f20d
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Thu Mar 5 11:01:33 2026 -0600
minor items
---
.../java/org/codehaus/groovy/ast/AnnotationNode.java | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/main/java/org/codehaus/groovy/ast/AnnotationNode.java b/src/main/java/org/codehaus/groovy/ast/AnnotationNode.java
index d43197be20..a7fe7f4a7c 100644
--- a/src/main/java/org/codehaus/groovy/ast/AnnotationNode.java
+++ b/src/main/java/org/codehaus/groovy/ast/AnnotationNode.java
@@ -245,17 +245,17 @@ public class AnnotationNode extends ASTNode {
}
public static String targetToName(final int target) {
+ if ((target & 1) == 1) return "TYPE"; // GROOVY-7151
return switch (target) {
- case TYPE_TARGET -> "TYPE";
- case CONSTRUCTOR_TARGET -> "CONSTRUCTOR";
- case METHOD_TARGET -> "METHOD";
- case FIELD_TARGET -> "FIELD";
- case PARAMETER_TARGET -> "PARAMETER";
- case LOCAL_VARIABLE_TARGET -> "LOCAL_VARIABLE";
- case ANNOTATION_TARGET -> "ANNOTATION";
- case PACKAGE_TARGET -> "PACKAGE";
- case TYPE_PARAMETER_TARGET -> "TYPE_PARAMETER";
- case TYPE_USE_TARGET -> "TYPE_USE";
+ case CONSTRUCTOR_TARGET -> "CONSTRUCTOR";
+ case METHOD_TARGET -> "METHOD";
+ case FIELD_TARGET -> "FIELD";
+ case PARAMETER_TARGET -> "PARAMETER";
+ case LOCAL_VARIABLE_TARGET -> "LOCAL_VARIABLE";
+ case ANNOTATION_TARGET -> "ANNOTATION";
+ case PACKAGE_TARGET -> "PACKAGE";
+ case TYPE_PARAMETER_TARGET -> "TYPE_PARAMETER";
+ case TYPE_USE_TARGET -> "TYPE_USE";
case RECORD_COMPONENT_TARGET -> "RECORD_COMPONENT";
default -> "unknown target";
};
(groovy) 02/03: GROOVY-6526: compute retention policy lazily
Posted by em...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
emilles pushed a commit to branch GROOVY-6526
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit b8d64b47270825381e4c2076a7187f83470d6db5
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Thu Mar 5 10:35:55 2026 -0600
GROOVY-6526: compute retention policy lazily
---
.../org/codehaus/groovy/ast/AnnotationNode.java | 59 +++++++++++-----------
.../codehaus/groovy/classgen/ExtendedVerifier.java | 6 +--
.../org/codehaus/groovy/vmplugin/VMPlugin.java | 14 +++--
.../org/codehaus/groovy/vmplugin/v8/Java8.java | 50 +++---------------
.../codehaus/groovy/ast/AnnotationNodeTest.groovy | 36 +++++++++++++
5 files changed, 86 insertions(+), 79 deletions(-)
diff --git a/src/main/java/org/codehaus/groovy/ast/AnnotationNode.java b/src/main/java/org/codehaus/groovy/ast/AnnotationNode.java
index d125fff2d6..d43197be20 100644
--- a/src/main/java/org/codehaus/groovy/ast/AnnotationNode.java
+++ b/src/main/java/org/codehaus/groovy/ast/AnnotationNode.java
@@ -25,6 +25,8 @@ import org.codehaus.groovy.ast.expr.ListExpression;
import org.codehaus.groovy.ast.expr.PropertyExpression;
import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.Collections;
import java.util.LinkedHashMap;
@@ -52,7 +54,6 @@ public class AnnotationNode extends ASTNode {
private final ClassNode classNode;
private Map<String, Expression> members;
- private boolean runtimeRetention = false, sourceRetention = false, /*explicit*/ classRetention = false;
public AnnotationNode(final ClassNode type) {
classNode = requireNonNull(type);
@@ -83,34 +84,16 @@ public class AnnotationNode extends ASTNode {
public void setAllowedTargets(final int ignored) {
}
- /**
- * Sets the internal flag if the current annotation has <code>RetentionPolicy.RUNTIME</code>.
- *
- * @param value if <tt>true</tt> then current annotation is marked as having
- * <code>RetentionPolicy.RUNTIME</code>.
- */
- public void setRuntimeRetention(final boolean value) {
- runtimeRetention = value;
+ @Deprecated(since = "6.0.0")
+ public void setClassRetention(final boolean ignored) {
}
- /**
- * Sets the internal flag if the current annotation has <code>RetentionPolicy.SOURCE</code>.
- *
- * @param value if <tt>true</tt> then current annotation is marked as having
- * <code>RetentionPolicy.SOURCE</code>.
- */
- public void setSourceRetention(final boolean value) {
- sourceRetention = value;
+ @Deprecated(since = "6.0.0")
+ public void setSourceRetention(final boolean ignored) {
}
- /**
- * Sets the internal flag if the current annotation has an explicit <code>RetentionPolicy.CLASS</code>.
- *
- * @param value if <tt>true</tt> then current annotation is marked as having
- * <code>RetentionPolicy.CLASS</code>.
- */
- public void setClassRetention(final boolean value) {
- classRetention = value;
+ @Deprecated(since = "6.0.0")
+ public void setRuntimeRetention(final boolean ignored) {
}
//--------------------------------------------------------------------------
@@ -177,6 +160,24 @@ public class AnnotationNode extends ASTNode {
return (target & allowedTargets) == target;
}
+ private RetentionPolicy getRetentionPolicy() {
+ if (!(classNode.isPrimaryClassNode() || classNode.isResolved()))
+ throw new IllegalStateException("cannot check retention at this time");
+
+ // GROOVY-6526: check class for @Retention
+ return classNode.getNodeMetaData(Retention.class, (k) -> {
+ for (AnnotationNode an : classNode.getAnnotations()) {
+ if ("java.lang.annotation.Retention".equals(an.getClassNode().getName())) {
+ if (an.getMember("value") instanceof PropertyExpression pe) {
+ return RetentionPolicy.valueOf(pe.getPropertyAsString());
+ }
+ break;
+ }
+ }
+ return null;
+ });
+ }
+
/**
* Flag corresponding to <code>RetentionPolicy.RUNTIME</code>.
*
@@ -184,7 +185,7 @@ public class AnnotationNode extends ASTNode {
* <tt>false</tt> otherwise
*/
public boolean hasRuntimeRetention() {
- return this.runtimeRetention;
+ return RetentionPolicy.RUNTIME.equals(getRetentionPolicy());
}
/**
@@ -194,7 +195,7 @@ public class AnnotationNode extends ASTNode {
* <tt>false</tt> otherwise
*/
public boolean hasSourceRetention() {
- return this.sourceRetention;
+ return RetentionPolicy.SOURCE.equals(getRetentionPolicy());
}
/**
@@ -205,8 +206,8 @@ public class AnnotationNode extends ASTNode {
* <tt>false</tt> otherwise
*/
public boolean hasClassRetention() {
- if (!runtimeRetention && !sourceRetention) return true;
- return this.classRetention;
+ RetentionPolicy retentionPolicy = getRetentionPolicy();
+ return retentionPolicy == null || retentionPolicy.equals(RetentionPolicy.CLASS);
}
@Override
diff --git a/src/main/java/org/codehaus/groovy/classgen/ExtendedVerifier.java b/src/main/java/org/codehaus/groovy/classgen/ExtendedVerifier.java
index 9649ab87c4..917d08ce67 100644
--- a/src/main/java/org/codehaus/groovy/classgen/ExtendedVerifier.java
+++ b/src/main/java/org/codehaus/groovy/classgen/ExtendedVerifier.java
@@ -35,7 +35,6 @@ import org.codehaus.groovy.ast.expr.ClassExpression;
import org.codehaus.groovy.ast.expr.ConstructorCallExpression;
import org.codehaus.groovy.ast.expr.DeclarationExpression;
import org.codehaus.groovy.ast.expr.Expression;
-import org.codehaus.groovy.ast.expr.PropertyExpression;
import org.codehaus.groovy.ast.stmt.ReturnStatement;
import org.codehaus.groovy.ast.stmt.Statement;
import org.codehaus.groovy.control.AnnotationConstantsVisitor;
@@ -43,7 +42,6 @@ import org.codehaus.groovy.control.ErrorCollector;
import org.codehaus.groovy.control.SourceUnit;
import org.objectweb.asm.Opcodes;
-import java.lang.annotation.Retention;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -67,13 +65,11 @@ import static org.codehaus.groovy.ast.AnnotationNode.TYPE_TARGET;
import static org.codehaus.groovy.ast.AnnotationNode.TYPE_USE_TARGET;
import static org.codehaus.groovy.ast.ClassHelper.DEPRECATED_TYPE;
import static org.codehaus.groovy.ast.ClassHelper.isPrimitiveVoid;
-import static org.codehaus.groovy.ast.ClassHelper.makeCached;
import static org.codehaus.groovy.ast.tools.GeneralUtils.listX;
import static org.codehaus.groovy.ast.tools.GenericsUtils.correctToGenericsSpec;
import static org.codehaus.groovy.ast.tools.GenericsUtils.createGenericsSpec;
import static org.codehaus.groovy.ast.tools.GenericsUtils.parameterizeType;
import static org.codehaus.groovy.ast.tools.ParameterUtils.parametersEqual;
-import static org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.evaluateExpression;
/**
* A specialized Groovy AST visitor meant to perform additional verifications upon the
@@ -377,6 +373,7 @@ public class ExtendedVerifier extends ClassCodeVisitorSupport {
addError("Cannot specify duplicate annotation on the same member. Explicit " + repeatable.getName() + " found when creating implicit container for " + entry.getKey(), node);
}
AnnotationNode collector = new AnnotationNode(repeatable);
+/*
if (repeatee.hasClassRetention()) {
collector.setClassRetention(true);
} else if (repeatee.hasRuntimeRetention()) {
@@ -398,6 +395,7 @@ public class ExtendedVerifier extends ClassCodeVisitorSupport {
}
}
}
+*/
collector.addMember("value", listX(entry.getValue().stream().map(AnnotationConstantExpression::new).collect(toList())));
node.getAnnotations().removeAll(entry.getValue());
node.addAnnotation(collector);
diff --git a/src/main/java/org/codehaus/groovy/vmplugin/VMPlugin.java b/src/main/java/org/codehaus/groovy/vmplugin/VMPlugin.java
index 602b452bf6..17e7e21686 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/VMPlugin.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/VMPlugin.java
@@ -40,13 +40,19 @@ import java.util.Set;
* This interface is for internal use only!
*/
public interface VMPlugin {
- void setAdditionalClassInformation(ClassNode c);
+
Class[] getPluginDefaultGroovyMethods();
Class[] getPluginStaticGroovyMethods();
- void configureAnnotationNodeFromDefinition(AnnotationNode definition, AnnotationNode root);
- void configureAnnotation(AnnotationNode an);
- void configureClassNode(CompileUnit compileUnit, ClassNode classNode);
+
+ void setAdditionalClassInformation(ClassNode node);
+ void configureClassNode(CompileUnit unit, ClassNode node);
+
+ void configureAnnotation(AnnotationNode node);
+ default void configureAnnotationNodeFromDefinition(AnnotationNode definition, AnnotationNode node) {
+ }
+
void invalidateCallSites();
+
/**
* Returns a handle with bound receiver to invokeSpecial the given method.
* This method will require at least Java 7, but since the source has to compile
diff --git a/src/main/java/org/codehaus/groovy/vmplugin/v8/Java8.java b/src/main/java/org/codehaus/groovy/vmplugin/v8/Java8.java
index 2e31e7e3bb..826a177b86 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/v8/Java8.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/v8/Java8.java
@@ -118,22 +118,6 @@ public class Java8 implements VMPlugin {
}
}
- private static void setRetentionPolicy(final RetentionPolicy value, final AnnotationNode node) {
- switch (value) {
- case RUNTIME:
- node.setRuntimeRetention(true);
- break;
- case SOURCE:
- node.setSourceRetention(true);
- break;
- case CLASS:
- node.setClassRetention(true);
- break;
- default:
- throw new GroovyBugError("unsupported Retention " + value);
- }
- }
-
//--------------------------------------------------------------------------
@Override
@@ -269,27 +253,19 @@ public class Java8 implements VMPlugin {
}
private void configureAnnotation(final AnnotationNode node, final Annotation annotation) {
- Class<?> type = annotation.annotationType();
- if (type == Retention.class) {
- Retention r = (Retention) annotation;
- RetentionPolicy value = r.value();
- setRetentionPolicy(value, node);
- node.setMember("value", new PropertyExpression(
- new ClassExpression(ClassHelper.makeWithoutCaching(RetentionPolicy.class, false)),
- value.toString()));
- } else if (type == Target.class) {
- Target t = (Target) annotation;
- ElementType[] elements = t.value();
- ListExpression elementExprs = new ListExpression();
- for (ElementType element : elements) {
- elementExprs.addExpression(new PropertyExpression(
- new ClassExpression(ClassHelper.ELEMENT_TYPE_TYPE), element.name()));
+ if (annotation instanceof Retention r) {
+ final ClassNode retentionPolicy = ClassHelper.makeWithoutCaching(RetentionPolicy.class, false);
+ node.setMember("value", new PropertyExpression(new ClassExpression(retentionPolicy), r.value().toString()));
+ } else if (annotation instanceof Target t) {
+ var elementExprs = new ListExpression();
+ for (ElementType elementTypes : t.value()) {
+ elementExprs.addExpression(new PropertyExpression(new ClassExpression(ClassHelper.ELEMENT_TYPE_TYPE), elementTypes.name()));
}
node.setMember("value", elementExprs);
} else {
Method[] declaredMethods;
try {
- declaredMethods = type.getDeclaredMethods();
+ declaredMethods = annotation.annotationType().getDeclaredMethods();
} catch (SecurityException se) {
declaredMethods = EMPTY_METHOD_ARRAY;
}
@@ -298,7 +274,6 @@ public class Java8 implements VMPlugin {
Object value = declaredMethod.invoke(annotation);
Expression valueExpression = toAnnotationValueExpression(value);
if (valueExpression != null) node.setMember(declaredMethod.getName(), valueExpression);
-
} catch (IllegalAccessException | InvocationTargetException ignore) {
}
}
@@ -341,15 +316,6 @@ public class Java8 implements VMPlugin {
return null;
}
- @Override
- public void configureAnnotationNodeFromDefinition(final AnnotationNode definition, final AnnotationNode node) {
- if ("java.lang.annotation.Retention".equals(definition.getClassNode().getName())
- && definition.getMember("value") instanceof PropertyExpression value) {
- var policy = RetentionPolicy.valueOf(value.getPropertyAsString());
- setRetentionPolicy(policy, node);
- }
- }
-
@Override
public void configureClassNode(final CompileUnit compileUnit, final ClassNode classNode) {
try {
diff --git a/src/test/groovy/org/codehaus/groovy/ast/AnnotationNodeTest.groovy b/src/test/groovy/org/codehaus/groovy/ast/AnnotationNodeTest.groovy
index ba2d0f671e..c52c0531d6 100644
--- a/src/test/groovy/org/codehaus/groovy/ast/AnnotationNodeTest.groovy
+++ b/src/test/groovy/org/codehaus/groovy/ast/AnnotationNodeTest.groovy
@@ -69,6 +69,42 @@ final class AnnotationNodeTest {
assertFalse(node.isTargetAllowed(TYPE_PARAMETER_TARGET))
}
+ @Test
+ void testRetentionPolicy1() {
+ def node = new AnnotationNode(ClassHelper.make(gls.annotations.HasExplicitClassRetention))
+
+ assertTrue (node.hasClassRetention())
+ assertFalse(node.hasSourceRetention())
+ assertFalse(node.hasRuntimeRetention())
+ }
+
+ @Test
+ void testRetentionPolicy2() {
+ def node = new AnnotationNode(ClassHelper.OVERRIDE_TYPE)
+
+ assertFalse(node.hasClassRetention())
+ assertTrue (node.hasSourceRetention())
+ assertFalse(node.hasRuntimeRetention())
+ }
+
+ @Test
+ void testRetentionPolicy3() {
+ def node = new AnnotationNode(ClassHelper.DEPRECATED_TYPE)
+
+ assertFalse(node.hasClassRetention())
+ assertFalse(node.hasSourceRetention())
+ assertTrue (node.hasRuntimeRetention())
+ }
+
+ @Test
+ void testRetentionPolicy4() {
+ def node = new AnnotationNode(new ClassNode("A", 0x2000, ClassHelper.Annotation_TYPE))
+
+ assertTrue (node.hasClassRetention())
+ assertFalse(node.hasSourceRetention())
+ assertFalse(node.hasRuntimeRetention())
+ }
+
@Test
void testGetText() {
def node = new AnnotationNode(ClassHelper.OVERRIDE_TYPE)
(groovy) 01/03: GROOVY-6526: compute allowed targets lazily
Posted by em...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
emilles pushed a commit to branch GROOVY-6526
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit 88e170b4687eb0545579863091175d9681857ea6
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Sun Mar 1 14:28:02 2026 -0600
GROOVY-6526: compute allowed targets lazily
---
.../org/codehaus/groovy/ast/AnnotationNode.java | 55 ++++++++++++++++++----
.../groovy/ast/decompiled/Annotations.java | 3 +-
.../org/codehaus/groovy/vmplugin/v16/Java16.java | 6 ---
.../org/codehaus/groovy/vmplugin/v8/Java8.java | 43 ++---------------
.../org/codehaus/groovy/vmplugin/v9/Java9.java | 7 ---
.../codehaus/groovy/ast/AnnotationNodeTest.groovy | 47 ++++++++++++++----
6 files changed, 91 insertions(+), 70 deletions(-)
diff --git a/src/main/java/org/codehaus/groovy/ast/AnnotationNode.java b/src/main/java/org/codehaus/groovy/ast/AnnotationNode.java
index b39906a136..d125fff2d6 100644
--- a/src/main/java/org/codehaus/groovy/ast/AnnotationNode.java
+++ b/src/main/java/org/codehaus/groovy/ast/AnnotationNode.java
@@ -22,7 +22,10 @@ import org.codehaus.groovy.GroovyBugError;
import org.codehaus.groovy.ast.expr.ConstantExpression;
import org.codehaus.groovy.ast.expr.Expression;
import org.codehaus.groovy.ast.expr.ListExpression;
+import org.codehaus.groovy.ast.expr.PropertyExpression;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -49,7 +52,6 @@ public class AnnotationNode extends ASTNode {
private final ClassNode classNode;
private Map<String, Expression> members;
- private int allowedTargets = 0x4FF; // GROOVY-11838: JLS 9.6.4.1
private boolean runtimeRetention = false, sourceRetention = false, /*explicit*/ classRetention = false;
public AnnotationNode(final ClassNode type) {
@@ -77,8 +79,8 @@ public class AnnotationNode extends ASTNode {
}
}
- public void setAllowedTargets(final int bitmap) {
- allowedTargets = bitmap;
+ @Deprecated(since = "6.0.0")
+ public void setAllowedTargets(final int ignored) {
}
/**
@@ -137,12 +139,48 @@ public class AnnotationNode extends ASTNode {
}
public boolean isTargetAllowed(final int target) {
- return (this.allowedTargets & target) == target;
+ if (!(classNode.isPrimaryClassNode() || classNode.isResolved()))
+ throw new IllegalStateException("cannot check target at this time");
+
+ // GROOVY-6526: check class for @Target
+ int allowedTargets = classNode.getNodeMetaData(Target.class, (k) -> {
+ for (AnnotationNode an : classNode.getAnnotations()) {
+ if ("java.lang.annotation.Target".equals(an.getClassNode().getName())
+ && an.getMember("value") instanceof ListExpression list) {
+ int bits = 0;
+ for (Expression e : list.getExpressions()) {
+ if (e instanceof PropertyExpression item) {
+ String name = item.getPropertyAsString();
+ bits |= switch (ElementType.valueOf(name)) {
+ case TYPE -> TYPE_TARGET;
+ case FIELD -> FIELD_TARGET;
+ case METHOD -> METHOD_TARGET;
+ case PARAMETER -> PARAMETER_TARGET;
+ case CONSTRUCTOR -> CONSTRUCTOR_TARGET;
+ case LOCAL_VARIABLE -> LOCAL_VARIABLE_TARGET;
+ case ANNOTATION_TYPE -> ANNOTATION_TARGET;
+ case PACKAGE -> PACKAGE_TARGET;
+ case TYPE_PARAMETER -> TYPE_PARAMETER_TARGET;
+ case TYPE_USE -> TYPE_USE_TARGET;
+ case MODULE -> TYPE_TARGET; //TODO
+ case RECORD_COMPONENT -> RECORD_COMPONENT_TARGET;
+ default -> throw new GroovyBugError("unsupported Target " + name);
+ };
+ }
+ }
+ return bits;
+ }
+ }
+ return 0x4FF; // GROOVY-11838: JLS 9.6.4.1
+ });
+
+ return (target & allowedTargets) == target;
}
/**
* Flag corresponding to <code>RetentionPolicy.RUNTIME</code>.
- * @return <tt>true</tt> if the annotation should be visible at runtime,
+ *
+ * @return <tt>true</tt> if the annotation should be visible at runtime;
* <tt>false</tt> otherwise
*/
public boolean hasRuntimeRetention() {
@@ -151,7 +189,8 @@ public class AnnotationNode extends ASTNode {
/**
* Flag corresponding to <code>RetentionPolicy.SOURCE</code>.
- * @return <tt>true</tt> if the annotation is only allowed in sources
+ *
+ * @return <tt>true</tt> if the annotation is only allowed in sources;
* <tt>false</tt> otherwise
*/
public boolean hasSourceRetention() {
@@ -160,9 +199,9 @@ public class AnnotationNode extends ASTNode {
/**
* Flag corresponding to <code>RetentionPolicy.CLASS</code>.
- * This is the default when no <code>RetentionPolicy</code> annotations are present.
+ * This is the default when no <code>Retention</code> annotation is present.
*
- * @return <tt>true</tt> if the annotation is written in the bytecode, but not visible at runtime
+ * @return <tt>true</tt> if the annotation is written in the bytecode but not visible at runtime;
* <tt>false</tt> otherwise
*/
public boolean hasClassRetention() {
diff --git a/src/main/java/org/codehaus/groovy/ast/decompiled/Annotations.java b/src/main/java/org/codehaus/groovy/ast/decompiled/Annotations.java
index dbd671d7e9..713c75c398 100644
--- a/src/main/java/org/codehaus/groovy/ast/decompiled/Annotations.java
+++ b/src/main/java/org/codehaus/groovy/ast/decompiled/Annotations.java
@@ -143,8 +143,7 @@ class Annotations {
}
@Override
- public boolean isTargetAllowed(int target) {
- lazyInit();
+ public boolean isTargetAllowed(final int target) {
return super.isTargetAllowed(target);
}
diff --git a/src/main/java/org/codehaus/groovy/vmplugin/v16/Java16.java b/src/main/java/org/codehaus/groovy/vmplugin/v16/Java16.java
index f8169a73af..46bbcd5f45 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/v16/Java16.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/v16/Java16.java
@@ -20,13 +20,11 @@ package org.codehaus.groovy.vmplugin.v16;
import groovy.lang.GroovyRuntimeException;
import org.apache.groovy.lang.annotation.Incubating;
-import org.codehaus.groovy.ast.AnnotationNode;
import org.codehaus.groovy.ast.ClassNode;
import org.codehaus.groovy.ast.CompileUnit;
import org.codehaus.groovy.ast.RecordComponentNode;
import org.codehaus.groovy.vmplugin.v10.Java10;
-import java.lang.annotation.ElementType;
import java.lang.invoke.MethodHandle;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
@@ -37,10 +35,6 @@ import java.util.stream.Collectors;
public class Java16 extends Java10 {
- {
- elementTypeToTarget.put(ElementType.RECORD_COMPONENT, AnnotationNode.RECORD_COMPONENT_TARGET);
- }
-
@Override
public int getVersion() {
return 16;
diff --git a/src/main/java/org/codehaus/groovy/vmplugin/v8/Java8.java b/src/main/java/org/codehaus/groovy/vmplugin/v8/Java8.java
index 67860da52a..2e31e7e3bb 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/v8/Java8.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/v8/Java8.java
@@ -20,7 +20,6 @@ package org.codehaus.groovy.vmplugin.v8;
import groovy.lang.MetaClass;
import groovy.lang.MetaMethod;
-import org.apache.groovy.util.Maps;
import org.codehaus.groovy.GroovyBugError;
import org.codehaus.groovy.ast.AnnotatedNode;
import org.codehaus.groovy.ast.AnnotationNode;
@@ -70,9 +69,7 @@ import java.lang.reflect.TypeVariable;
import java.lang.reflect.WildcardType;
import java.security.Permission;
import java.util.Arrays;
-import java.util.EnumMap;
import java.util.List;
-import java.util.Map;
/**
* Java 8 based functions.
@@ -344,44 +341,12 @@ public class Java8 implements VMPlugin {
return null;
}
- //
-
- protected final Map<ElementType, Integer> elementTypeToTarget = new EnumMap<>(Maps.of(
- ElementType.TYPE, AnnotationNode.TYPE_TARGET,
- ElementType.FIELD, AnnotationNode.FIELD_TARGET,
- ElementType.METHOD, AnnotationNode.METHOD_TARGET,
- ElementType.PARAMETER, AnnotationNode.PARAMETER_TARGET,
- ElementType.CONSTRUCTOR, AnnotationNode.CONSTRUCTOR_TARGET,
- ElementType.LOCAL_VARIABLE, AnnotationNode.LOCAL_VARIABLE_TARGET,
- ElementType.ANNOTATION_TYPE, AnnotationNode.ANNOTATION_TARGET,
- ElementType.PACKAGE, AnnotationNode.PACKAGE_TARGET,
- ElementType.TYPE_PARAMETER, AnnotationNode.TYPE_PARAMETER_TARGET,
- ElementType.TYPE_USE, AnnotationNode.TYPE_USE_TARGET
- ));
-
@Override
public void configureAnnotationNodeFromDefinition(final AnnotationNode definition, final AnnotationNode node) {
- switch (definition.getClassNode().getName()) {
- case "java.lang.annotation.Retention":
- if (definition.getMember("value") instanceof PropertyExpression value) {
- var policy = RetentionPolicy.valueOf(value.getPropertyAsString());
- setRetentionPolicy(policy, node);
- }
- break;
- case "java.lang.annotation.Target":
- if (definition.getMember("value") instanceof ListExpression list) {
- int targets = 0;
- for (Expression e : list.getExpressions()) {
- if (e instanceof PropertyExpression item) {
- String name = item.getPropertyAsString();
- ElementType type = ElementType.valueOf(name);
- Integer target = elementTypeToTarget.get(type);
- if (target == null) throw new GroovyBugError("unsupported Target " + type);
- targets |= target;
- }
- }
- node.setAllowedTargets(targets);
- }
+ if ("java.lang.annotation.Retention".equals(definition.getClassNode().getName())
+ && definition.getMember("value") instanceof PropertyExpression value) {
+ var policy = RetentionPolicy.valueOf(value.getPropertyAsString());
+ setRetentionPolicy(policy, node);
}
}
diff --git a/src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java b/src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java
index 6981ee17a2..2f0af57de4 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/v9/Java9.java
@@ -56,15 +56,8 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
-import static java.lang.annotation.ElementType.MODULE;
-import static org.codehaus.groovy.ast.AnnotationNode.TYPE_TARGET;
-
public class Java9 extends Java8 {
- {
- elementTypeToTarget.put(MODULE, TYPE_TARGET); // TODO Add MODULE_TARGET?
- }
-
@Override
public int getVersion() {
return 9;
diff --git a/src/test/groovy/org/codehaus/groovy/ast/AnnotationNodeTest.groovy b/src/test/groovy/org/codehaus/groovy/ast/AnnotationNodeTest.groovy
index aa33bcdcc7..ba2d0f671e 100644
--- a/src/test/groovy/org/codehaus/groovy/ast/AnnotationNodeTest.groovy
+++ b/src/test/groovy/org/codehaus/groovy/ast/AnnotationNodeTest.groovy
@@ -21,21 +21,52 @@ package org.codehaus.groovy.ast
import org.codehaus.groovy.ast.expr.ConstantExpression
import org.junit.jupiter.api.Test
+import static org.codehaus.groovy.ast.AnnotationNode.*
import static org.junit.jupiter.api.Assertions.*
final class AnnotationNodeTest {
- // GROOVY-11838
+ // GROOVY-6526
@Test
- void testIsTargetAllowed() {
+ void testIsTargetAllowed1() {
def node = new AnnotationNode(ClassHelper.OVERRIDE_TYPE)
- assertTrue(node.isTargetAllowed(AnnotationNode.TYPE_TARGET))
- assertTrue(node.isTargetAllowed(AnnotationNode.FIELD_TARGET))
- assertTrue(node.isTargetAllowed(AnnotationNode.METHOD_TARGET))
+ assertTrue(node.isTargetAllowed(METHOD_TARGET))
+
+ for (target in [TYPE_TARGET, CONSTRUCTOR_TARGET, FIELD_TARGET, PARAMETER_TARGET,
+ LOCAL_VARIABLE_TARGET, ANNOTATION_TARGET, PACKAGE_TARGET,
+ TYPE_PARAMETER_TARGET, TYPE_USE_TARGET, RECORD_COMPONENT_TARGET]) {
+ assertFalse(node.isTargetAllowed(target))
+ }
+ }
+
+ // GROOVY-6526
+ @Test
+ void testIsTargetAllowed2() {
+ def node = new AnnotationNode(ClassHelper.DEPRECATED_TYPE)
+
+ for (target in [TYPE_TARGET, CONSTRUCTOR_TARGET, METHOD_TARGET, FIELD_TARGET,
+ LOCAL_VARIABLE_TARGET, PARAMETER_TARGET, PACKAGE_TARGET]) {
+ assertTrue(node.isTargetAllowed(target))
+ }
+
+ for (target in [TYPE_PARAMETER_TARGET, TYPE_USE_TARGET, RECORD_COMPONENT_TARGET]) {
+ assertFalse(node.isTargetAllowed(target))
+ }
+ }
+
+ // GROOVY-11838
+ @Test
+ void testIsTargetAllowed3() {
+ def node = new AnnotationNode(new ClassNode("A", 0x2000, ClassHelper.Annotation_TYPE))
- assertFalse(node.isTargetAllowed(AnnotationNode.TYPE_USE_TARGET))
- assertFalse(node.isTargetAllowed(AnnotationNode.TYPE_PARAMETER_TARGET))
+ for (target in [TYPE_TARGET, CONSTRUCTOR_TARGET, METHOD_TARGET, FIELD_TARGET,
+ PARAMETER_TARGET, LOCAL_VARIABLE_TARGET, ANNOTATION_TARGET,
+ PACKAGE_TARGET, RECORD_COMPONENT_TARGET]) {
+ assertTrue(node.isTargetAllowed(target))
+ }
+ assertFalse(node.isTargetAllowed(TYPE_USE_TARGET))
+ assertFalse(node.isTargetAllowed(TYPE_PARAMETER_TARGET))
}
@Test
@@ -47,7 +78,7 @@ final class AnnotationNodeTest {
@Test
void testGetText2() {
- def node = new AnnotationNode(ClassHelper.make(Deprecated))
+ def node = new AnnotationNode(ClassHelper.DEPRECATED_TYPE)
node.addMember('since', new ConstantExpression('1.2.3'))
assertEquals('@java.lang.Deprecated(since="1.2.3")', node.getText())