changeset 25536:075b9f8a32d8

Eliminate -Xlint warnings during Java compilation (bug #53550). * ClassHelper.java: Fill in @throws invocations with full error message. Use StringBuilder rather than StringBuffer. Parametize types in function declarations. * Octave.java: Declare type in LinkedList declarations.
author Andrew Janke <andrew@apjanke.net>
date Mon, 02 Jul 2018 08:20:34 -0700
parents ad25dee33a9f
children 975450679c15
files scripts/java/org/octave/ClassHelper.java scripts/java/org/octave/Octave.java
diffstat 2 files changed, 14 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/java/org/octave/ClassHelper.java	Mon Jul 02 15:48:14 2018 +0200
+++ b/scripts/java/org/octave/ClassHelper.java	Mon Jul 02 08:20:34 2018 -0700
@@ -40,7 +40,7 @@
    * Add the given path to the classpath.
    * @param name String - path to addd to the classpath
    * @return boolean - true if the given path exists and was added to the classpath.
-   * @throws Exception
+   * @throws Exception if an error occurs
    */
   public static boolean addClassPath (String name)
     throws Exception
@@ -61,7 +61,7 @@
    *
    * @param name String - path to remove from classpath.
    * @return boolean - true if the given path existed in the classpath before it was removed.
-   * @throws Exception
+   * @throws Exception if an error occurs
    */
   public static boolean removeClassPath (String name)
     throws Exception
@@ -98,7 +98,7 @@
 
   public static String getClassPath ()
   {
-    StringBuffer buf = new StringBuffer ();
+    StringBuilder buf = new StringBuilder();
     String pathSep = System.getProperty ("path.separator");
     java.net.URL[] urls = loader.getURLs ();
 
@@ -142,7 +142,7 @@
   // return list of methods for given class
   public static String getMethods (Class klass)
   {
-    StringBuffer sb = new StringBuffer ();
+    StringBuilder sb = new StringBuilder();
 
     Method theMethod[] = klass.getMethods ();
     for (int i = 0; i < theMethod.length; i++)
@@ -190,7 +190,7 @@
   // return list of fields for given class
   public static String getFields (Class klass)
   {
-    StringBuffer sb = new StringBuffer ();
+    StringBuilder sb = new StringBuilder();
 
     Field theField[] = klass.getFields ();
     for (int i = 0; i < theField.length; i++)
@@ -224,7 +224,7 @@
   }
 
 
-  public static Method findMethod (Class cls, String name, Class[] argTypes)
+  public static Method findMethod (Class<?> cls, String name, Class<?>[] argTypes)
   {
     try
       {
@@ -249,7 +249,7 @@
   }
 
 
-  public static Constructor findConstructor (Class cls, Class[] argTypes)
+  public static Constructor findConstructor (Class<?> cls, Class<?>[] argTypes)
   {
     try
       {
@@ -285,8 +285,8 @@
     catch (IllegalAccessException ex)
       {
         String mName = m.getName ();
-        Class[] pTypes = m.getParameterTypes ();
-        Class currClass = target.getClass ();
+        Class<?>[] pTypes = m.getParameterTypes ();
+        Class<?> currClass = target.getClass ();
 
         while (currClass != null)
           {
@@ -303,7 +303,7 @@
             catch (IllegalAccessException ex2)
               {}
 
-            Class[] ifaceList = currClass.getInterfaces ();
+            Class<?>[] ifaceList = currClass.getInterfaces ();
             for (int i = 0; i < ifaceList.length; i++)
               {
                 try
@@ -492,7 +492,7 @@
   }
 
 
-  private static boolean isCallableFrom (Class expCls, Class argCls)
+  private static boolean isCallableFrom (Class<?> expCls, Class<?> argCls)
   {
     //System.out.println("isCallableFrom: "+expCls.getCanonicalName() + " <=? " + argCls.getCanonicalName());
     if (argCls == null)
@@ -598,7 +598,7 @@
   }
 
 
-  private static Object castArgument (Object obj, Class type, Class expType)
+  private static Object castArgument (Object obj, Class<?> type, Class<?> expType)
   {
     // System.out.println("expType:"+expType.getCanonicalName() + " <= type:" + type.getCanonicalName());
     if (type == null || expType.isAssignableFrom (type))
--- a/scripts/java/org/octave/Octave.java	Mon Jul 02 15:48:14 2018 +0200
+++ b/scripts/java/org/octave/Octave.java	Mon Jul 02 08:20:34 2018 -0700
@@ -28,8 +28,8 @@
 {
   private static Object notifyObject = null;
   private static Object[] args = null;
-  private static LinkedList invokeList = new LinkedList ();
-  private static LinkedList waitList = new LinkedList ();
+  private static LinkedList<Object> invokeList = new LinkedList<Object> ();
+  private static LinkedList<Object> waitList = new LinkedList<Object> ();
 
   public native static boolean call (String name, Object[] argin, Object[] argout);
   public native static void doInvoke (int ID, Object[] args);