diff --git a/build-logic/src/main/groovy/org/apache/groovy/gradle/WriteExtensionDescriptorTask.groovy b/build-logic/src/main/groovy/org/apache/groovy/gradle/WriteExtensionDescriptorTask.groovy index 0e021df9b4b..72a62f0387c 100644 --- a/build-logic/src/main/groovy/org/apache/groovy/gradle/WriteExtensionDescriptorTask.groovy +++ b/build-logic/src/main/groovy/org/apache/groovy/gradle/WriteExtensionDescriptorTask.groovy @@ -35,8 +35,8 @@ class WriteExtensionDescriptorTask extends DefaultTask { @OutputFile File descriptor = computeDescriptorFile() private File computeDescriptorFile() { - def metaInfDir = new File("${project.buildDir}/resources/main/META-INF/groovy") - return new File(metaInfDir, "org.codehaus.groovy.runtime.ExtensionModule") + def metaInfDir = project.layout.buildDirectory.dir('/resources/main/META-INF/groovy').get() + return new File(metaInfDir, 'org.codehaus.groovy.runtime.ExtensionModule') } @TaskAction diff --git a/src/main/groovy/groovy/util/ConfigSlurper.groovy b/src/main/groovy/groovy/util/ConfigSlurper.groovy index d7f47d54c36..c16bceb6cfb 100644 --- a/src/main/groovy/groovy/util/ConfigSlurper.groovy +++ b/src/main/groovy/groovy/util/ConfigSlurper.groovy @@ -150,7 +150,7 @@ class ConfigSlurper { * @see ConfigSlurper#parse(groovy.lang.Script) */ ConfigObject parse(Class scriptClass) { - parse(scriptClass.newInstance()) + parse(scriptClass.getConstructor().newInstance()) } /** @@ -171,7 +171,7 @@ class ConfigSlurper { * @return The ConfigObject instance */ ConfigObject parse(URL scriptLocation) { - parse(classLoader.parseClass(scriptLocation.text).newInstance(), scriptLocation) + parse(classLoader.parseClass(scriptLocation.text).getConstructor().newInstance(), scriptLocation) } /** diff --git a/src/main/groovy/org/codehaus/groovy/control/customizers/ASTTransformationCustomizer.groovy b/src/main/groovy/org/codehaus/groovy/control/customizers/ASTTransformationCustomizer.groovy index 6c3d3f6ba6b..2d430614102 100644 --- a/src/main/groovy/org/codehaus/groovy/control/customizers/ASTTransformationCustomizer.groovy +++ b/src/main/groovy/org/codehaus/groovy/control/customizers/ASTTransformationCustomizer.groovy @@ -104,7 +104,7 @@ class ASTTransformationCustomizer extends CompilationCustomizer implements Compi ASTTransformationCustomizer(Class transformationAnnotation, String astTransformationClassName, ClassLoader transformationClassLoader) { super(findPhase(transformationAnnotation, astTransformationClassName, transformationClassLoader)) Class clazz = findASTTransformationClass(transformationAnnotation, astTransformationClassName, transformationClassLoader) - this.transformation = clazz.newInstance() + this.transformation = clazz.getConstructor().newInstance() this.annotationNode = new AnnotationNode(ClassHelper.make(transformationAnnotation)) } @@ -132,7 +132,7 @@ class ASTTransformationCustomizer extends CompilationCustomizer implements Compi ASTTransformationCustomizer(Map annotationParams, Class transformationAnnotation, String astTransformationClassName, ClassLoader transformationClassLoader) { super(findPhase(transformationAnnotation, astTransformationClassName, transformationClassLoader)) Class clazz = findASTTransformationClass(transformationAnnotation, astTransformationClassName, transformationClassLoader) - this.transformation = clazz.newInstance() + this.transformation = clazz.getConstructor().newInstance() this.annotationNode = new AnnotationNode(ClassHelper.make(transformationAnnotation)) this.annotationParameters = annotationParams } @@ -150,7 +150,7 @@ class ASTTransformationCustomizer extends CompilationCustomizer implements Compi ASTTransformationCustomizer(Class transformationAnnotation, ClassLoader transformationClassLoader) { super(findPhase(transformationAnnotation, transformationClassLoader)) Class clazz = findASTTransformationClass(transformationAnnotation, transformationClassLoader) - this.transformation = clazz.newInstance() + this.transformation = clazz.getConstructor().newInstance() this.annotationNode = new AnnotationNode(ClassHelper.make(transformationAnnotation)) } @@ -181,7 +181,7 @@ class ASTTransformationCustomizer extends CompilationCustomizer implements Compi ASTTransformationCustomizer(Map annotationParams, Class transformationAnnotation, ClassLoader transformationClassLoader) { super(findPhase(transformationAnnotation, transformationClassLoader)) Class clazz = findASTTransformationClass(transformationAnnotation, transformationClassLoader) - this.transformation = clazz.newInstance() + this.transformation = clazz.getConstructor().newInstance() this.annotationNode = new AnnotationNode(ClassHelper.make(transformationAnnotation)) this.annotationParameters = annotationParams } @@ -229,13 +229,13 @@ class ASTTransformationCustomizer extends CompilationCustomizer implements Compi private static CompilePhase findPhase(Class annotationClass, ClassLoader transformationClassLoader) { Class clazz = findASTTransformationClass(annotationClass, transformationClassLoader) - findPhase(clazz.newInstance()) + findPhase(clazz.getConstructor().newInstance()) } private static CompilePhase findPhase(Class annotationClass, String astTransformationClassName, ClassLoader transformationClassLoader) { Class clazz = findASTTransformationClass(annotationClass, astTransformationClassName, transformationClassLoader) - findPhase(clazz.newInstance()) + findPhase(clazz.getConstructor().newInstance()) } /** diff --git a/subprojects/groovy-console/src/main/groovy/groovy/console/ui/Console.groovy b/subprojects/groovy-console/src/main/groovy/groovy/console/ui/Console.groovy index 8fa8c5a3315..2139b85fee3 100644 --- a/subprojects/groovy-console/src/main/groovy/groovy/console/ui/Console.groovy +++ b/subprojects/groovy-console/src/main/groovy/groovy/console/ui/Console.groovy @@ -373,7 +373,7 @@ class Console implements CaretListener, HyperlinkListener, ComponentListener, Fo try { if (Class.forName('org.apache.ivy.core.event.IvyListener')) { def ivyPluginClass = Class.forName('groovy.console.ui.ConsoleIvyPlugin') - ivyPluginClass.newInstance().addListener(this) + ivyPluginClass.getConstructor().newInstance().addListener(this) } } catch (ClassNotFoundException ignore) { } diff --git a/subprojects/groovy-swing/src/main/groovy/groovy/swing/LookAndFeelHelper.groovy b/subprojects/groovy-swing/src/main/groovy/groovy/swing/LookAndFeelHelper.groovy index a88467d6ccd..975b7a71a12 100644 --- a/subprojects/groovy-swing/src/main/groovy/groovy/swing/LookAndFeelHelper.groovy +++ b/subprojects/groovy-swing/src/main/groovy/groovy/swing/LookAndFeelHelper.groovy @@ -72,11 +72,11 @@ class LookAndFeelHelper { theme : { laf, theme -> if (!(theme instanceof MetalTheme)) { if (theme == 'ocean') { - theme = Class.forName('javax.swing.plaf.metal.OceanTheme').newInstance() + theme = Class.forName('javax.swing.plaf.metal.OceanTheme').getConstructor().newInstance() } else if (theme == 'steel') { theme = new DefaultMetalTheme(); } else { - theme = Class.forName(theme as String).newInstance() + theme = Class.forName(theme as String).getConstructor().newInstance() } }; MetalLookAndFeel.currentTheme = theme diff --git a/subprojects/groovy-swing/src/main/groovy/groovy/swing/factory/BeanFactory.groovy b/subprojects/groovy-swing/src/main/groovy/groovy/swing/factory/BeanFactory.groovy index bf42e128293..f19385d609d 100644 --- a/subprojects/groovy-swing/src/main/groovy/groovy/swing/factory/BeanFactory.groovy +++ b/subprojects/groovy-swing/src/main/groovy/groovy/swing/factory/BeanFactory.groovy @@ -43,7 +43,7 @@ class BeanFactory extends AbstractFactory { if (FactoryBuilderSupport.checkValueIsTypeNotString(value, name, beanClass)) { return value } - Object bean = beanClass.newInstance() + Object bean = beanClass.getConstructor().newInstance() if (value instanceof String) { try { bean.text = value diff --git a/subprojects/groovy-swing/src/main/groovy/groovy/swing/factory/ColumnFactory.groovy b/subprojects/groovy-swing/src/main/groovy/groovy/swing/factory/ColumnFactory.groovy index cdc6748e7ad..fc086bd3710 100644 --- a/subprojects/groovy-swing/src/main/groovy/groovy/swing/factory/ColumnFactory.groovy +++ b/subprojects/groovy-swing/src/main/groovy/groovy/swing/factory/ColumnFactory.groovy @@ -40,7 +40,7 @@ class ColumnFactory extends AbstractFactory { } if (jxTableClass != null && builder.current instanceof TableColumnModel) { - node = Class.forName("org.jdesktop.swingx.table.TableColumnExt").newInstance() + node = Class.forName("org.jdesktop.swingx.table.TableColumnExt").getConstructor().newInstance() } else { node = new javax.swing.table.TableColumn() } diff --git a/subprojects/groovy-swing/src/main/groovy/groovy/swing/factory/ColumnModelFactory.groovy b/subprojects/groovy-swing/src/main/groovy/groovy/swing/factory/ColumnModelFactory.groovy index a43b432e0a0..ec020cd8c18 100644 --- a/subprojects/groovy-swing/src/main/groovy/groovy/swing/factory/ColumnModelFactory.groovy +++ b/subprojects/groovy-swing/src/main/groovy/groovy/swing/factory/ColumnModelFactory.groovy @@ -38,7 +38,7 @@ class ColumnModelFactory extends AbstractFactory { } if (jxTableClass != null && jxTableClass.isAssignableFrom(builder.current.getClass())) { - return Class.forName("org.jdesktop.swingx.table.DefaultTableColumnModelExt").newInstance() + return Class.forName("org.jdesktop.swingx.table.DefaultTableColumnModelExt").ngetConstructor().newInstance() } else { return new javax.swing.table.DefaultTableColumnModel() } diff --git a/subprojects/groovy-swing/src/main/groovy/groovy/swing/factory/TextArgWidgetFactory.groovy b/subprojects/groovy-swing/src/main/groovy/groovy/swing/factory/TextArgWidgetFactory.groovy index 8ffc8472dcf..beeafc51c7c 100644 --- a/subprojects/groovy-swing/src/main/groovy/groovy/swing/factory/TextArgWidgetFactory.groovy +++ b/subprojects/groovy-swing/src/main/groovy/groovy/swing/factory/TextArgWidgetFactory.groovy @@ -34,7 +34,7 @@ class TextArgWidgetFactory extends AbstractFactory { return value } - Object widget = klass.newInstance() + Object widget = klass.getConstructor().newInstance() if (value instanceof String) { // this does not create property setting order issues, since the value arg precedes all attributes in the builder element diff --git a/subprojects/groovy-test/src/main/groovy/groovy/mock/interceptor/MockFor.groovy b/subprojects/groovy-test/src/main/groovy/groovy/mock/interceptor/MockFor.groovy index 82f7c982118..519c49a6d04 100644 --- a/subprojects/groovy-test/src/main/groovy/groovy/mock/interceptor/MockFor.groovy +++ b/subprojects/groovy-test/src/main/groovy/groovy/mock/interceptor/MockFor.groovy @@ -285,12 +285,12 @@ class MockFor { } } else { if (GroovyObject.isAssignableFrom(clazz)) { - instance = clazz.newInstance() + instance = clazz.getConstructor().newInstance() } else { - instance = ProxyGenerator.INSTANCE.instantiateDelegate(clazz.newInstance()) + instance = ProxyGenerator.INSTANCE.instantiateDelegate(clazz.getConstructor().newInstance()) } } return instance } -} \ No newline at end of file +} diff --git a/subprojects/groovy-test/src/main/groovy/groovy/test/JavadocAssertionTestSuite.groovy b/subprojects/groovy-test/src/main/groovy/groovy/test/JavadocAssertionTestSuite.groovy index 9b1b3313a1e..f3d7e0429fa 100644 --- a/subprojects/groovy-test/src/main/groovy/groovy/test/JavadocAssertionTestSuite.groovy +++ b/subprojects/groovy-test/src/main/groovy/groovy/test/JavadocAssertionTestSuite.groovy @@ -69,7 +69,7 @@ class JavadocAssertionTestSuite extends TestSuite { public static final String SYSPROP_SRC_EXCLUDES_PATTERN = "javadocAssertion.src.excludesPattern"; private static final JavadocAssertionTestBuilder testBuilder = new JavadocAssertionTestBuilder() - private static final IFileNameFinder finder = Class.forName('groovy.ant.FileNameFinder',true,this.classLoader).newInstance() + private static final IFileNameFinder finder = Class.forName('groovy.ant.FileNameFinder',true,this.classLoader).getConstructor().newInstance() static Test suite() { String basedir = System.getProperty(SYSPROP_SRC_DIR, "./src/")