This is an automated email from the ASF dual-hosted git repository.

joshtynjala pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git

commit 352d641e17b5ff6c03779edd4721ff8bc4c70d37
Author: Josh Tynjala <[email protected]>
AuthorDate: Thu Jun 20 14:33:28 2024 -0700

    class.newInstance() is deprecated, replace with recommended 
class.getConstructor().newInstance() instead
---
 .../royale/compiler/config/ConfigurationBuffer.java    | 13 +++++++++++--
 .../apache/royale/compiler/config/Configurator.java    |  4 ++--
 .../flex2/compiler/config/ConfigurationBuffer.java     | 18 ++++++++++++++----
 .../royale/formatter/config/ConfigurationBuffer.java   | 13 +++++++++++--
 .../royale/linter/config/ConfigurationBuffer.java      | 13 +++++++++++--
 .../org/apache/royale/linter/config/Configurator.java  |  4 ++--
 6 files changed, 51 insertions(+), 14 deletions(-)

diff --git 
a/compiler-common/src/main/java/org/apache/royale/compiler/config/ConfigurationBuffer.java
 
b/compiler-common/src/main/java/org/apache/royale/compiler/config/ConfigurationBuffer.java
index c9ed7c1f2..17d81b7f9 100644
--- 
a/compiler-common/src/main/java/org/apache/royale/compiler/config/ConfigurationBuffer.java
+++ 
b/compiler-common/src/main/java/org/apache/royale/compiler/config/ConfigurationBuffer.java
@@ -888,7 +888,7 @@ public final class ConfigurationBuffer
             Class<?>[] pt = info.getSetterMethod().getParameterTypes();
             assert (pt.length == 2); // assumed to be checked upstream
 
-            Object o = pt[1].newInstance();
+            Object o = pt[1].getConstructor().newInstance();
 
             Field[] fields = pt[1].getFields();
 
@@ -930,11 +930,20 @@ public final class ConfigurationBuffer
 
             return o;
         }
+        catch (NoSuchMethodException e)
+        {
+            assert false : ("coding error: unable to find value object 
constructor when trying to set var " + cv.getVar());
+            throw new ConfigurationException.OtherThrowable(e, cv.getVar(), 
cv.getSource(), cv.getLine());
+        }
+        catch (InvocationTargetException e)
+        {
+            assert false : ("coding error: unable to invoke value object 
constructor when trying to set var " + cv.getVar());
+            throw new ConfigurationException.OtherThrowable(e, cv.getVar(), 
cv.getSource(), cv.getLine());
+        }
         catch (InstantiationException e)
         {
             assert false : ("coding error: unable to instantiate value object 
when trying to set var " + cv.getVar());
             throw new ConfigurationException.OtherThrowable(e, cv.getVar(), 
cv.getSource(), cv.getLine());
-
         }
         catch (IllegalAccessException e)
         {
diff --git 
a/compiler-common/src/main/java/org/apache/royale/compiler/config/Configurator.java
 
b/compiler-common/src/main/java/org/apache/royale/compiler/config/Configurator.java
index e8fd19566..d519ac09e 100644
--- 
a/compiler-common/src/main/java/org/apache/royale/compiler/config/Configurator.java
+++ 
b/compiler-common/src/main/java/org/apache/royale/compiler/config/Configurator.java
@@ -487,7 +487,7 @@ public class Configurator implements ICompilerSettings, 
IConfigurator, ICompiler
     {
         try
         {
-            return configurationClass.newInstance();
+            return configurationClass.getConstructor().newInstance();
         }
         catch (Exception e)
         {
@@ -499,7 +499,7 @@ public class Configurator implements ICompilerSettings, 
IConfigurator, ICompiler
             // problems.
             try
             {
-                return Configuration.class.newInstance();                
+                return Configuration.class.getConstructor().newInstance();     
           
             }
             catch (Exception e2)
             {
diff --git 
a/flex-compiler-oem/src/main/java/flex2/compiler/config/ConfigurationBuffer.java
 
b/flex-compiler-oem/src/main/java/flex2/compiler/config/ConfigurationBuffer.java
index a6c3a4e23..f16cd9447 100644
--- 
a/flex-compiler-oem/src/main/java/flex2/compiler/config/ConfigurationBuffer.java
+++ 
b/flex-compiler-oem/src/main/java/flex2/compiler/config/ConfigurationBuffer.java
@@ -829,21 +829,21 @@ public final class ConfigurationBuffer
     {
         try
         {
-            Class[] pt = info.getSetterMethod().getParameterTypes();
+            Class<?>[] pt = info.getSetterMethod().getParameterTypes();
             assert ( pt.length == 2 ); // assumed to be checked upstream
 
-            Object o = pt[1].newInstance();
+            Object o = pt[1].getConstructor().newInstance();
 
             Field[] fields = pt[1].getFields();
 
             assert ( fields.length == cv.getArgs().size() );   // assumed to 
be checked upstream
 
-            Iterator argsit = cv.getArgs().iterator();
+            Iterator<String> argsit = cv.getArgs().iterator();
             for (int f = 0; f < fields.length; ++f)
             {
                 String val = (String) argsit.next();
                 Object valobj = null;
-                Class fc = fields[f].getType();
+                Class<?> fc = fields[f].getType();
 
                 assert ( info.getArgType( f ) == fc );
                 assert ( info.getArgName( f ).equals( ConfigurationBuffer.c2h( 
fields[f].getName() )) );
@@ -874,6 +874,16 @@ public final class ConfigurationBuffer
 
             return o;
         }
+        catch (NoSuchMethodException e)
+        {
+            assert false : ("coding error: unable to find value object 
constructor when trying to set var " + cv.getVar());
+            throw new ConfigurationException.OtherThrowable(e, cv.getVar(), 
cv.getSource(), cv.getLine());
+        }
+        catch (InvocationTargetException e)
+        {
+            assert false : ("coding error: unable to invoke value object 
constructor when trying to set var " + cv.getVar());
+            throw new ConfigurationException.OtherThrowable(e, cv.getVar(), 
cv.getSource(), cv.getLine());
+        }
         catch (InstantiationException e)
         {
             assert false : ( "coding error: unable to instantiate value object 
when trying to set var " + cv.getVar() );
diff --git 
a/formatter/src/main/java/org/apache/royale/formatter/config/ConfigurationBuffer.java
 
b/formatter/src/main/java/org/apache/royale/formatter/config/ConfigurationBuffer.java
index 917d9858d..38f2bd82d 100644
--- 
a/formatter/src/main/java/org/apache/royale/formatter/config/ConfigurationBuffer.java
+++ 
b/formatter/src/main/java/org/apache/royale/formatter/config/ConfigurationBuffer.java
@@ -888,7 +888,7 @@ public final class ConfigurationBuffer
             Class<?>[] pt = info.getSetterMethod().getParameterTypes();
             assert (pt.length == 2); // assumed to be checked upstream
 
-            Object o = pt[1].newInstance();
+            Object o = pt[1].getConstructor().newInstance();
 
             Field[] fields = pt[1].getFields();
 
@@ -930,11 +930,20 @@ public final class ConfigurationBuffer
 
             return o;
         }
+        catch (NoSuchMethodException e)
+        {
+            assert false : ("coding error: unable to find value object 
constructor when trying to set var " + cv.getVar());
+            throw new ConfigurationException.OtherThrowable(e, cv.getVar(), 
cv.getSource(), cv.getLine());
+        }
+        catch (InvocationTargetException e)
+        {
+            assert false : ("coding error: unable to invoke value object 
constructor when trying to set var " + cv.getVar());
+            throw new ConfigurationException.OtherThrowable(e, cv.getVar(), 
cv.getSource(), cv.getLine());
+        }
         catch (InstantiationException e)
         {
             assert false : ("coding error: unable to instantiate value object 
when trying to set var " + cv.getVar());
             throw new ConfigurationException.OtherThrowable(e, cv.getVar(), 
cv.getSource(), cv.getLine());
-
         }
         catch (IllegalAccessException e)
         {
diff --git 
a/linter/src/main/java/org/apache/royale/linter/config/ConfigurationBuffer.java 
b/linter/src/main/java/org/apache/royale/linter/config/ConfigurationBuffer.java
index 557b60a97..01b82c940 100644
--- 
a/linter/src/main/java/org/apache/royale/linter/config/ConfigurationBuffer.java
+++ 
b/linter/src/main/java/org/apache/royale/linter/config/ConfigurationBuffer.java
@@ -888,7 +888,7 @@ public final class ConfigurationBuffer
             Class<?>[] pt = info.getSetterMethod().getParameterTypes();
             assert (pt.length == 2); // assumed to be checked upstream
 
-            Object o = pt[1].newInstance();
+            Object o = pt[1].getConstructor().newInstance();
 
             Field[] fields = pt[1].getFields();
 
@@ -930,11 +930,20 @@ public final class ConfigurationBuffer
 
             return o;
         }
+        catch (NoSuchMethodException e)
+        {
+            assert false : ("coding error: unable to find value object 
constructor when trying to set var " + cv.getVar());
+            throw new ConfigurationException.OtherThrowable(e, cv.getVar(), 
cv.getSource(), cv.getLine());
+        }
+        catch (InvocationTargetException e)
+        {
+            assert false : ("coding error: unable to invoke value object 
constructor when trying to set var " + cv.getVar());
+            throw new ConfigurationException.OtherThrowable(e, cv.getVar(), 
cv.getSource(), cv.getLine());
+        }
         catch (InstantiationException e)
         {
             assert false : ("coding error: unable to instantiate value object 
when trying to set var " + cv.getVar());
             throw new ConfigurationException.OtherThrowable(e, cv.getVar(), 
cv.getSource(), cv.getLine());
-
         }
         catch (IllegalAccessException e)
         {
diff --git 
a/linter/src/main/java/org/apache/royale/linter/config/Configurator.java 
b/linter/src/main/java/org/apache/royale/linter/config/Configurator.java
index 7a48189a2..b8219a9f4 100644
--- a/linter/src/main/java/org/apache/royale/linter/config/Configurator.java
+++ b/linter/src/main/java/org/apache/royale/linter/config/Configurator.java
@@ -235,7 +235,7 @@ public class Configurator implements Cloneable
     {
         try
         {
-            return configurationClass.newInstance();
+            return configurationClass.getConstructor().newInstance();
         }
         catch (Exception e)
         {
@@ -247,7 +247,7 @@ public class Configurator implements Cloneable
             // problems.
             try
             {
-                return Configuration.class.newInstance();                
+                return Configuration.class.getConstructor().newInstance();     
           
             }
             catch (Exception e2)
             {

Reply via email to