Skip to content

Commit

Permalink
avoid deprecated usage
Browse files Browse the repository at this point in the history
  • Loading branch information
paulk-asert committed Jan 5, 2025
1 parent 306ba36 commit f9a7971
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/main/groovy/groovy/util/ConfigSlurper.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class ConfigSlurper {
* @see ConfigSlurper#parse(groovy.lang.Script)
*/
ConfigObject parse(Class scriptClass) {
parse(scriptClass.newInstance())
parse(scriptClass.getConstructor().newInstance())
}

/**
Expand All @@ -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)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class ASTTransformationCustomizer extends CompilationCustomizer implements Compi
ASTTransformationCustomizer(Class<? extends Annotation> transformationAnnotation, String astTransformationClassName, ClassLoader transformationClassLoader) {
super(findPhase(transformationAnnotation, astTransformationClassName, transformationClassLoader))
Class<ASTTransformation> clazz = findASTTransformationClass(transformationAnnotation, astTransformationClassName, transformationClassLoader)
this.transformation = clazz.newInstance()
this.transformation = clazz.getConstructor().newInstance()
this.annotationNode = new AnnotationNode(ClassHelper.make(transformationAnnotation))
}

Expand Down Expand Up @@ -132,7 +132,7 @@ class ASTTransformationCustomizer extends CompilationCustomizer implements Compi
ASTTransformationCustomizer(Map annotationParams, Class<? extends Annotation> transformationAnnotation, String astTransformationClassName, ClassLoader transformationClassLoader) {
super(findPhase(transformationAnnotation, astTransformationClassName, transformationClassLoader))
Class<ASTTransformation> clazz = findASTTransformationClass(transformationAnnotation, astTransformationClassName, transformationClassLoader)
this.transformation = clazz.newInstance()
this.transformation = clazz.getConstructor().newInstance()
this.annotationNode = new AnnotationNode(ClassHelper.make(transformationAnnotation))
this.annotationParameters = annotationParams
}
Expand All @@ -150,7 +150,7 @@ class ASTTransformationCustomizer extends CompilationCustomizer implements Compi
ASTTransformationCustomizer(Class<? extends Annotation> transformationAnnotation, ClassLoader transformationClassLoader) {
super(findPhase(transformationAnnotation, transformationClassLoader))
Class<ASTTransformation> clazz = findASTTransformationClass(transformationAnnotation, transformationClassLoader)
this.transformation = clazz.newInstance()
this.transformation = clazz.getConstructor().newInstance()
this.annotationNode = new AnnotationNode(ClassHelper.make(transformationAnnotation))
}

Expand Down Expand Up @@ -181,7 +181,7 @@ class ASTTransformationCustomizer extends CompilationCustomizer implements Compi
ASTTransformationCustomizer(Map annotationParams, Class<? extends Annotation> transformationAnnotation, ClassLoader transformationClassLoader) {
super(findPhase(transformationAnnotation, transformationClassLoader))
Class<ASTTransformation> clazz = findASTTransformationClass(transformationAnnotation, transformationClassLoader)
this.transformation = clazz.newInstance()
this.transformation = clazz.getConstructor().newInstance()
this.annotationNode = new AnnotationNode(ClassHelper.make(transformationAnnotation))
this.annotationParameters = annotationParams
}
Expand Down Expand Up @@ -229,13 +229,13 @@ class ASTTransformationCustomizer extends CompilationCustomizer implements Compi
private static CompilePhase findPhase(Class<? extends Annotation> annotationClass, ClassLoader transformationClassLoader) {
Class<ASTTransformation> clazz = findASTTransformationClass(annotationClass, transformationClassLoader)

findPhase(clazz.newInstance())
findPhase(clazz.getConstructor().newInstance())
}

private static CompilePhase findPhase(Class<? extends Annotation> annotationClass, String astTransformationClassName, ClassLoader transformationClassLoader) {
Class<ASTTransformation> clazz = findASTTransformationClass(annotationClass, astTransformationClassName, transformationClassLoader)

findPhase(clazz.newInstance())
findPhase(clazz.getConstructor().newInstance())
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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/")
Expand Down

0 comments on commit f9a7971

Please sign in to comment.