You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jdo-commits@db.apache.org by mb...@apache.org on 2022/08/13 19:35:39 UTC

[db-jdo] branch tck-compiler-warnings updated (3064d3bf -> 6084535e)

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

mbo pushed a change to branch tck-compiler-warnings
in repository https://gitbox.apache.org/repos/asf/db-jdo.git


    from 3064d3bf JDO-817 removing compiler warnings: method close w/o throws clause in Query and Extent
     new 350df7bf JDO-817 removing compiler warnings: „redundant cast“ in api submodule
     new 85189119 DO-817 removing compiler warnings: „serializable class has no definition of serialVersionUID“ in api submodule
     new 38048f5d JDO-817 removing compiler warnings: "raw use of parameterized class" in api submodule
     new 7ca32adb JDO-817 removing compiler warnings: "raw use of parameterized class" in api submodule
     new 6ff57322 JDO-817 removing compiler warnings: „static method declared final“ in api submodule
     new 7f1ea284 JDO-817 removing compiler warnings: „while loop replaceable with enhanced for loop“ in api submodule
     new 6084535e JDO-817 removing compiler warnings: „anonymous can be replaced by lambda“ in api submodule

The 7 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:
 api/src/main/java/javax/jdo/Enhancer.java          |   8 +-
 api/src/main/java/javax/jdo/JDOHelper.java         | 156 +++++----------------
 .../main/java/javax/jdo/annotations/Element.java   |   2 +-
 api/src/main/java/javax/jdo/annotations/Key.java   |   2 +-
 .../java/javax/jdo/annotations/Persistent.java     |   2 +-
 api/src/main/java/javax/jdo/annotations/Value.java |   2 +-
 .../main/java/javax/jdo/identity/ByteIdentity.java |   4 +-
 .../main/java/javax/jdo/identity/CharIdentity.java |   2 +
 .../main/java/javax/jdo/identity/IntIdentity.java  |   2 +
 .../main/java/javax/jdo/identity/LongIdentity.java |   4 +-
 .../java/javax/jdo/identity/ObjectIdentity.java    |  13 +-
 .../java/javax/jdo/identity/ShortIdentity.java     |   4 +-
 .../javax/jdo/identity/SingleFieldIdentity.java    |   8 +-
 .../java/javax/jdo/identity/StringIdentity.java    |   6 +-
 api/src/main/java/javax/jdo/spi/I18NHelper.java    |  40 ++----
 api/src/main/java/javax/jdo/spi/JDOImplHelper.java |  56 +++-----
 .../test/java/javax/jdo/AbstractJDOConfigTest.java |   6 +-
 api/src/test/java/javax/jdo/EnhancerTest.java      |  22 ++-
 .../test/java/javax/jdo/JDOHelperConfigTest.java   |   2 +-
 api/src/test/java/javax/jdo/JDOHelperTest.java     |   6 +-
 api/src/test/java/javax/jdo/PMFService.java        |   6 +-
 .../javax/jdo/identity/ConcreteTestIdentity.java   |  10 +-
 .../java/javax/jdo/identity/IntIdentityTest.java   |  18 +--
 .../javax/jdo/identity/ObjectIdentityTest.java     |  17 +--
 api/src/test/java/javax/jdo/pc/PCPoint.java        |  10 +-
 api/src/test/java/javax/jdo/schema/XMLTest.java    |   6 +-
 api/src/test/java/javax/jdo/stub/StubPMF.java      |   2 +-
 api/src/test/java/javax/jdo/util/XMLTestUtil.java  |  22 +--
 28 files changed, 158 insertions(+), 280 deletions(-)


[db-jdo] 05/07: JDO-817 removing compiler warnings: „static method declared final“ in api submodule

Posted by mb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mbo pushed a commit to branch tck-compiler-warnings
in repository https://gitbox.apache.org/repos/asf/db-jdo.git

commit 6ff57322ce5a4ca3526cd5772ce4eacd9b4b8ec4
Author: Michael Bouschen <Mi...@akquinet.de>
AuthorDate: Sat Aug 13 21:03:52 2022 +0200

    JDO-817 removing compiler warnings: „static method declared final“ in api submodule
---
 api/src/main/java/javax/jdo/spi/I18NHelper.java | 18 +++++++++---------
 api/src/test/java/javax/jdo/pc/PCPoint.java     | 10 +++++-----
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/api/src/main/java/javax/jdo/spi/I18NHelper.java b/api/src/main/java/javax/jdo/spi/I18NHelper.java
index 4e4a0d3a..161bf844 100644
--- a/api/src/main/java/javax/jdo/spi/I18NHelper.java
+++ b/api/src/main/java/javax/jdo/spi/I18NHelper.java
@@ -227,7 +227,7 @@ public class I18NHelper {
      * @param loader the class loader from which to load the resource bundle
      * @return  the ResourceBundle
      */
-    final private static ResourceBundle loadBundle(
+    private static ResourceBundle loadBundle(
         String bundleName, ClassLoader loader) {
         ResourceBundle messages = bundles.get(bundleName);
 
@@ -276,7 +276,7 @@ public class I18NHelper {
      * @param messageKey the message key
      * @return the resolved message text
      */
-    final private static String getMessage(ResourceBundle messages, String messageKey) 
+    private static String getMessage(ResourceBundle messages, String messageKey)
     {
         return messages.getString(messageKey);
     }
@@ -288,7 +288,7 @@ public class I18NHelper {
      * @param msgArgs an array of arguments to substitute into the message
      * @return the resolved message text
      */
-    final private static String getMessage(ResourceBundle messages, 
+    private static String getMessage(ResourceBundle messages,
             String messageKey, Object[] msgArgs) 
     {
         for (int i=0; i<msgArgs.length; i++) {
@@ -305,7 +305,7 @@ public class I18NHelper {
      * @param arg the argument
      * @return the resolved message text
      */
-    final private static String getMessage(ResourceBundle messages, 
+    private static String getMessage(ResourceBundle messages,
             String messageKey, Object arg) 
     {
         Object []args = {arg};
@@ -320,7 +320,7 @@ public class I18NHelper {
      * @param arg2 the second argument
      * @return the resolved message text
      */
-    final private static String getMessage(ResourceBundle messages, 
+    private static String getMessage(ResourceBundle messages,
             String messageKey, Object arg1, Object arg2) 
     {
         Object []args = {arg1, arg2};
@@ -336,7 +336,7 @@ public class I18NHelper {
      * @param arg3 the third argument
      * @return the resolved message text
      */
-    final private static String getMessage(ResourceBundle messages, 
+    private static String getMessage(ResourceBundle messages,
             String messageKey, Object arg1, Object arg2, Object arg3) 
     {
         Object []args = {arg1, arg2, arg3};
@@ -350,7 +350,7 @@ public class I18NHelper {
      * @param arg the argument
      * @return the resolved message text
      */
-    final private static String getMessage(ResourceBundle messages, 
+    private static String getMessage(ResourceBundle messages,
             String messageKey, int arg) 
     {
         Object []args = {Integer.valueOf(arg)};
@@ -364,7 +364,7 @@ public class I18NHelper {
      * @param arg the argument
      * @return the resolved message text
      */
-    final private static String getMessage(ResourceBundle messages, 
+    private static String getMessage(ResourceBundle messages,
             String messageKey, boolean arg) 
     {
         Object []args = {String.valueOf(arg)};
@@ -377,7 +377,7 @@ public class I18NHelper {
      * package 
      * @return package portion of the specified class
      */   
-    final private static String getPackageName(final String className)
+    private static String getPackageName(final String className)
     { 
         final int index = className.lastIndexOf('.');
         return ((index != -1) ? className.substring(0, index) : ""); // NOI18N
diff --git a/api/src/test/java/javax/jdo/pc/PCPoint.java b/api/src/test/java/javax/jdo/pc/PCPoint.java
index cb30c4d5..4eb8fcc9 100644
--- a/api/src/test/java/javax/jdo/pc/PCPoint.java
+++ b/api/src/test/java/javax/jdo/pc/PCPoint.java
@@ -296,7 +296,7 @@ public class PCPoint
         return 2;
     }
 
-     public static final int jdoGetx(PCPoint pcpoint) {
+     public static int jdoGetx(PCPoint pcpoint) {
         if (pcpoint.jdoFlags <= PersistenceCapable.READ_WRITE_OK)
             return pcpoint.x;
         StateManager statemanager = pcpoint.jdoStateManager;
@@ -309,7 +309,7 @@ public class PCPoint
                 pcpoint, jdoInheritedFieldCount + 0, pcpoint.x);
     }
 
-    public static final Integer jdoGety(PCPoint pcpoint) {
+    public static Integer jdoGety(PCPoint pcpoint) {
         if (pcpoint.jdoFlags <= PersistenceCapable.READ_WRITE_OK)
             return pcpoint.y;
         StateManager statemanager = pcpoint.jdoStateManager;
@@ -322,7 +322,7 @@ public class PCPoint
                 pcpoint, jdoInheritedFieldCount + 1, pcpoint.y);
     }
 
-    public static final void jdoSetx(PCPoint pcpoint, int i) {
+    public static void jdoSetx(PCPoint pcpoint, int i) {
         if (pcpoint.jdoFlags == PersistenceCapable.READ_WRITE_OK) {
             pcpoint.x = i;
             return;
@@ -339,7 +339,7 @@ public class PCPoint
         }
     }
 
-    public static final void jdoSety(PCPoint pcpoint, Integer integer) {
+    public static void jdoSety(PCPoint pcpoint, Integer integer) {
         if (pcpoint.jdoFlags == PersistenceCapable.READ_WRITE_OK) {
             pcpoint.y = integer;
             return;
@@ -445,7 +445,7 @@ public class PCPoint
         out.defaultWriteObject();
     }
     
-    protected static final Class<?> sunjdo$classForName$(String s) {
+    protected static Class<?> sunjdo$classForName$(String s) {
         try {
             return Class.forName(s);
         }


[db-jdo] 02/07: DO-817 removing compiler warnings: „serializable class has no definition of serialVersionUID“ in api submodule

Posted by mb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mbo pushed a commit to branch tck-compiler-warnings
in repository https://gitbox.apache.org/repos/asf/db-jdo.git

commit 85189119adc4c1c320862487086b2eac6854055e
Author: Michael Bouschen <Mi...@akquinet.de>
AuthorDate: Sat Aug 13 20:38:30 2022 +0200

    DO-817 removing compiler warnings: „serializable class has no definition of serialVersionUID“ in api submodule
---
 api/src/main/java/javax/jdo/identity/ByteIdentity.java         | 4 +++-
 api/src/main/java/javax/jdo/identity/CharIdentity.java         | 2 ++
 api/src/main/java/javax/jdo/identity/IntIdentity.java          | 2 ++
 api/src/main/java/javax/jdo/identity/LongIdentity.java         | 4 +++-
 api/src/main/java/javax/jdo/identity/ObjectIdentity.java       | 4 +++-
 api/src/main/java/javax/jdo/identity/ShortIdentity.java        | 4 +++-
 api/src/main/java/javax/jdo/identity/SingleFieldIdentity.java  | 4 +++-
 api/src/main/java/javax/jdo/identity/StringIdentity.java       | 4 +++-
 api/src/test/java/javax/jdo/identity/ConcreteTestIdentity.java | 4 +++-
 9 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/api/src/main/java/javax/jdo/identity/ByteIdentity.java b/api/src/main/java/javax/jdo/identity/ByteIdentity.java
index 53c9d224..0db3047b 100644
--- a/api/src/main/java/javax/jdo/identity/ByteIdentity.java
+++ b/api/src/main/java/javax/jdo/identity/ByteIdentity.java
@@ -30,7 +30,9 @@ import java.io.ObjectOutput;
  * @version 2.0
  */
 public class ByteIdentity extends SingleFieldIdentity<ByteIdentity> {
-    
+
+    private static final long serialVersionUID = 1L;
+
     /** The key.
      */
     private byte key;
diff --git a/api/src/main/java/javax/jdo/identity/CharIdentity.java b/api/src/main/java/javax/jdo/identity/CharIdentity.java
index 31d7a82a..80f86922 100644
--- a/api/src/main/java/javax/jdo/identity/CharIdentity.java
+++ b/api/src/main/java/javax/jdo/identity/CharIdentity.java
@@ -33,6 +33,8 @@ import javax.jdo.spi.I18NHelper;
  */
 public class CharIdentity extends SingleFieldIdentity<CharIdentity> {
 
+    private static final long serialVersionUID = 1L;
+
     /** The Internationalization message helper.
      */
     private static I18NHelper msg = I18NHelper.getInstance ("javax.jdo.Bundle"); //NOI18N
diff --git a/api/src/main/java/javax/jdo/identity/IntIdentity.java b/api/src/main/java/javax/jdo/identity/IntIdentity.java
index cdeb9914..8398096e 100644
--- a/api/src/main/java/javax/jdo/identity/IntIdentity.java
+++ b/api/src/main/java/javax/jdo/identity/IntIdentity.java
@@ -31,6 +31,8 @@ import java.io.ObjectOutput;
  */
 public class IntIdentity extends SingleFieldIdentity<IntIdentity> {
 
+    private static final long serialVersionUID = 1L;
+
     private int key;
 
     private void construct(int key) {
diff --git a/api/src/main/java/javax/jdo/identity/LongIdentity.java b/api/src/main/java/javax/jdo/identity/LongIdentity.java
index f3d6faab..53bc3c70 100644
--- a/api/src/main/java/javax/jdo/identity/LongIdentity.java
+++ b/api/src/main/java/javax/jdo/identity/LongIdentity.java
@@ -30,7 +30,9 @@ import java.io.ObjectOutput;
  * @version 2.0
  */
 public class LongIdentity extends SingleFieldIdentity<LongIdentity> {
-	
+
+    private static final long serialVersionUID = 1L;
+
     /** The key.
      */
     private long key;
diff --git a/api/src/main/java/javax/jdo/identity/ObjectIdentity.java b/api/src/main/java/javax/jdo/identity/ObjectIdentity.java
index f67e7370..6106d891 100644
--- a/api/src/main/java/javax/jdo/identity/ObjectIdentity.java
+++ b/api/src/main/java/javax/jdo/identity/ObjectIdentity.java
@@ -39,7 +39,9 @@ import javax.jdo.spi.JDOImplHelper;
  * @version 2.0
  */
 public class ObjectIdentity extends SingleFieldIdentity<ObjectIdentity> {
-    
+
+    private static final long serialVersionUID = 1L;
+
     /** The key is stored in the superclass field keyAsObject.
      */
     
diff --git a/api/src/main/java/javax/jdo/identity/ShortIdentity.java b/api/src/main/java/javax/jdo/identity/ShortIdentity.java
index bb7b9590..345bb650 100644
--- a/api/src/main/java/javax/jdo/identity/ShortIdentity.java
+++ b/api/src/main/java/javax/jdo/identity/ShortIdentity.java
@@ -31,7 +31,9 @@ import java.io.ObjectOutput;
  */
 public class ShortIdentity extends SingleFieldIdentity<ShortIdentity>
 {
-	private short key;
+    private static final long serialVersionUID = 1L;
+
+    private short key;
 
     private void construct(short key) {
         this.key = key;
diff --git a/api/src/main/java/javax/jdo/identity/SingleFieldIdentity.java b/api/src/main/java/javax/jdo/identity/SingleFieldIdentity.java
index fcd09168..7d23172b 100644
--- a/api/src/main/java/javax/jdo/identity/SingleFieldIdentity.java
+++ b/api/src/main/java/javax/jdo/identity/SingleFieldIdentity.java
@@ -41,7 +41,9 @@ import javax.jdo.spi.I18NHelper;
  */
 public abstract class SingleFieldIdentity<SUBCLASS extends SingleFieldIdentity<SUBCLASS>>
         implements Externalizable, Comparable<SUBCLASS>  {
-    
+
+    private static final long serialVersionUID = 1L;
+
     /** The Internationalization message helper.
      */
     protected static I18NHelper msg = I18NHelper.getInstance ("javax.jdo.Bundle"); //NOI18N
diff --git a/api/src/main/java/javax/jdo/identity/StringIdentity.java b/api/src/main/java/javax/jdo/identity/StringIdentity.java
index 9aff05ed..7a6a152a 100644
--- a/api/src/main/java/javax/jdo/identity/StringIdentity.java
+++ b/api/src/main/java/javax/jdo/identity/StringIdentity.java
@@ -30,7 +30,9 @@ import java.io.ObjectOutput;
  * @version 2.0
  */
 public class StringIdentity extends SingleFieldIdentity<StringIdentity> {
-    
+
+    private static final long serialVersionUID = 1L;
+
     /** The key is stored in the superclass field keyAsObject.
      */
     
diff --git a/api/src/test/java/javax/jdo/identity/ConcreteTestIdentity.java b/api/src/test/java/javax/jdo/identity/ConcreteTestIdentity.java
index 38e608d9..abbb72c2 100644
--- a/api/src/test/java/javax/jdo/identity/ConcreteTestIdentity.java
+++ b/api/src/test/java/javax/jdo/identity/ConcreteTestIdentity.java
@@ -31,7 +31,9 @@ import java.io.ObjectOutput;
  * @author clr
  */
     public class ConcreteTestIdentity extends SingleFieldIdentity {
-        
+
+        private static final long serialVersionUID = 1L;
+
         ConcreteTestIdentity(Class<?> cls) {
             super(cls);
         }


[db-jdo] 01/07: JDO-817 removing compiler warnings: „redundant cast“ in api submodule

Posted by mb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mbo pushed a commit to branch tck-compiler-warnings
in repository https://gitbox.apache.org/repos/asf/db-jdo.git

commit 350df7bfe7d9ba57e74286c0bae443e636254a56
Author: Michael Bouschen <Mi...@akquinet.de>
AuthorDate: Sat Aug 13 20:33:42 2022 +0200

    JDO-817 removing compiler warnings: „redundant cast“ in api submodule
---
 api/src/main/java/javax/jdo/JDOHelper.java         | 26 +++++++++-------------
 .../java/javax/jdo/identity/ObjectIdentity.java    |  2 +-
 .../java/javax/jdo/identity/StringIdentity.java    |  2 +-
 api/src/main/java/javax/jdo/spi/I18NHelper.java    |  6 ++---
 api/src/main/java/javax/jdo/spi/JDOImplHelper.java |  5 ++---
 .../test/java/javax/jdo/AbstractJDOConfigTest.java |  2 +-
 .../test/java/javax/jdo/JDOHelperConfigTest.java   |  2 +-
 api/src/test/java/javax/jdo/JDOHelperTest.java     |  6 ++---
 api/src/test/java/javax/jdo/PMFService.java        |  6 ++---
 .../java/javax/jdo/identity/IntIdentityTest.java   | 18 +++++++--------
 .../javax/jdo/identity/ObjectIdentityTest.java     |  2 +-
 api/src/test/java/javax/jdo/util/XMLTestUtil.java  | 10 ++++-----
 12 files changed, 40 insertions(+), 47 deletions(-)

diff --git a/api/src/main/java/javax/jdo/JDOHelper.java b/api/src/main/java/javax/jdo/JDOHelper.java
index cb5f6324..6dbcc4fe 100644
--- a/api/src/main/java/javax/jdo/JDOHelper.java
+++ b/api/src/main/java/javax/jdo/JDOHelper.java
@@ -175,7 +175,7 @@ public class JDOHelper implements Constants {
     /** The JDOImplHelper instance used for handling non-binary-compatible
      *  implementations.
      */
-    private static JDOImplHelper implHelper = (JDOImplHelper)
+    private static JDOImplHelper implHelper =
         doPrivileged(
             new PrivilegedAction<JDOImplHelper> () {
                 public JDOImplHelper run () {
@@ -842,8 +842,7 @@ public class JDOHelper implements Constants {
                 while (urls.hasMoreElements()) {
 
                     try {
-                        pmfClassName = getClassNameFromURL(
-                                (URL) urls.nextElement());
+                        pmfClassName = getClassNameFromURL(urls.nextElement());
 
                         // return the implementation that is valid.
                         PersistenceManagerFactory pmf = 
@@ -865,8 +864,7 @@ public class JDOHelper implements Constants {
 
         throw new JDOFatalUserException(msg.msg(
                 "EXC_GetPMFNoPMFClassNamePropertyOrPUNameProperty"),
-                (Throwable[])
-                    exceptions.toArray(new Throwable[exceptions.size()]));
+                exceptions.toArray(new Throwable[exceptions.size()]));
     }
 
     /** Get a class name from a URL. The URL is from getResources with 
@@ -1222,7 +1220,7 @@ public class JDOHelper implements Constants {
                 // then some kind of resource was found by the given name;
                 // assume that it's a properties file
                 props = new Properties();
-                ((Properties) props).load(in);
+                props.load(in);
             }
         } catch (IOException ioe) {
             throw new JDOFatalUserException(msg.msg(
@@ -1339,7 +1337,7 @@ public class JDOHelper implements Constants {
 
         // done with reading all config resources;
         // return what we found, which may very well be null
-        return (Map<Object,Object>) propertiesByNameInAllConfigs.get(name);
+        return propertiesByNameInAllConfigs.get(name);
     }
 
 
@@ -1563,8 +1561,7 @@ public class JDOHelper implements Constants {
             String attName = att.getNodeName();
             String attValue = att.getNodeValue().trim();
 
-            String jdoPropertyName =
-                (String) ATTRIBUTE_PROPERTY_XREF.get(attName);
+            String jdoPropertyName = ATTRIBUTE_PROPERTY_XREF.get(attName);
 
             p.put(
                 jdoPropertyName != null
@@ -1612,8 +1609,7 @@ public class JDOHelper implements Constants {
                 // <persistence-manager-factory> attribute names or the
                 // "javax.jdo" property names in <property> element "name"
                 // attributes.  Handy-dandy.
-                String jdoPropertyName =
-                    (String) ATTRIBUTE_PROPERTY_XREF.get(name);
+                String jdoPropertyName = ATTRIBUTE_PROPERTY_XREF.get(name);
                 
                 String propertyName = jdoPropertyName != null
                         ? jdoPropertyName
@@ -1883,7 +1879,7 @@ public class JDOHelper implements Constants {
                 while (urls.hasMoreElements()) {
                     numberOfJDOEnhancers++;
                     try {
-                        String enhancerClassName = getClassNameFromURL((URL)urls.nextElement());
+                        String enhancerClassName = getClassNameFromURL(urls.nextElement());
                         Class<?> enhancerClass = forName(enhancerClassName, true, ctrLoader);
                         JDOEnhancer enhancer = (JDOEnhancer)enhancerClass.newInstance();
                         return enhancer;
@@ -1898,7 +1894,7 @@ public class JDOHelper implements Constants {
         }
 
         throw new JDOFatalUserException(msg.msg("EXC_GetEnhancerNoValidEnhancerAvailable", numberOfJDOEnhancers),
-                (Throwable[])exceptions.toArray(new Throwable[exceptions.size()]));
+                exceptions.toArray(new Throwable[exceptions.size()]));
     }
 
     /** Get the context class loader associated with the current thread. 
@@ -1964,7 +1960,7 @@ public class JDOHelper implements Constants {
             final Object instance, final Object[] parameters) 
                 throws IllegalAccessException, InvocationTargetException {
         try {
-            return (Object) doPrivileged(
+            return doPrivileged(
                 new PrivilegedExceptionAction<Object>() {
                     public Object run() 
                         throws IllegalAccessException, 
@@ -1974,7 +1970,7 @@ public class JDOHelper implements Constants {
                 }
             );
         } catch (PrivilegedActionException ex) {
-            Exception cause = (Exception)ex.getException();
+            Exception cause = ex.getException();
             if (cause instanceof IllegalAccessException)
                 throw (IllegalAccessException)cause;
             else //if (cause instanceof InvocationTargetException)
diff --git a/api/src/main/java/javax/jdo/identity/ObjectIdentity.java b/api/src/main/java/javax/jdo/identity/ObjectIdentity.java
index 0c90a420..f67e7370 100644
--- a/api/src/main/java/javax/jdo/identity/ObjectIdentity.java
+++ b/api/src/main/java/javax/jdo/identity/ObjectIdentity.java
@@ -45,7 +45,7 @@ public class ObjectIdentity extends SingleFieldIdentity<ObjectIdentity> {
     
     /** The JDOImplHelper instance used for parsing the String to an Object.
      */
-    private static JDOImplHelper helper = (JDOImplHelper)
+    private static JDOImplHelper helper =
         doPrivileged(
             new PrivilegedAction<JDOImplHelper> () {
                 public JDOImplHelper run () {
diff --git a/api/src/main/java/javax/jdo/identity/StringIdentity.java b/api/src/main/java/javax/jdo/identity/StringIdentity.java
index 35e4a09a..9aff05ed 100644
--- a/api/src/main/java/javax/jdo/identity/StringIdentity.java
+++ b/api/src/main/java/javax/jdo/identity/StringIdentity.java
@@ -105,6 +105,6 @@ public class StringIdentity extends SingleFieldIdentity<StringIdentity> {
     public void readExternal(ObjectInput in)
 		throws IOException, ClassNotFoundException {
         super.readExternal (in);
-        keyAsObject = (String)in.readObject();
+        keyAsObject = in.readObject();
     }
 }
diff --git a/api/src/main/java/javax/jdo/spi/I18NHelper.java b/api/src/main/java/javax/jdo/spi/I18NHelper.java
index 5261f778..4e4a0d3a 100644
--- a/api/src/main/java/javax/jdo/spi/I18NHelper.java
+++ b/api/src/main/java/javax/jdo/spi/I18NHelper.java
@@ -127,7 +127,7 @@ public class I18NHelper {
      */
     public static I18NHelper getInstance (String bundleName, 
                                           ClassLoader loader) {
-        I18NHelper helper = (I18NHelper) helpers.get (bundleName);
+        I18NHelper helper = helpers.get (bundleName);
         if (helper != null) {
             return helper;
         }
@@ -135,7 +135,7 @@ public class I18NHelper {
         helpers.put (bundleName, helper);
         // if two threads simultaneously create the same helper, return the first
         // one to be put into the Hashtable.  The other will be garbage collected.
-        return (I18NHelper) helpers.get (bundleName);
+        return helpers.get (bundleName);
     }
 
     /** Message formatter
@@ -229,7 +229,7 @@ public class I18NHelper {
      */
     final private static ResourceBundle loadBundle(
         String bundleName, ClassLoader loader) {
-        ResourceBundle messages = (ResourceBundle)bundles.get(bundleName);
+        ResourceBundle messages = bundles.get(bundleName);
 
         if (messages == null) //not found as loaded - add
         {
diff --git a/api/src/main/java/javax/jdo/spi/JDOImplHelper.java b/api/src/main/java/javax/jdo/spi/JDOImplHelper.java
index edefeaf1..b036c9bf 100644
--- a/api/src/main/java/javax/jdo/spi/JDOImplHelper.java
+++ b/api/src/main/java/javax/jdo/spi/JDOImplHelper.java
@@ -549,7 +549,7 @@ public class JDOImplHelper extends java.lang.Object {
      * @return the <code>Meta</code> for the <code>Class</code>.
      */    
     private static Meta getMeta (Class<?> pcClass) {
-        Meta ret = (Meta) registeredClasses.get (pcClass);
+        Meta ret = registeredClasses.get (pcClass);
         if (ret == null) {
             throw new JDOFatalUserException(
                 msg.msg ("ERR_NoMetadata", pcClass.getName())); //NOI18N
@@ -836,8 +836,7 @@ public class JDOImplHelper extends java.lang.Object {
         try {
             Class<?> keyClass = Class.forName(className);
             synchronized(stringConstructorMap) {
-                stringConstructor = 
-                        (StringConstructor) stringConstructorMap.get(keyClass);
+                stringConstructor = stringConstructorMap.get(keyClass);
             }
             if (stringConstructor != null) {
                 return stringConstructor.construct(keyString);
diff --git a/api/src/test/java/javax/jdo/AbstractJDOConfigTest.java b/api/src/test/java/javax/jdo/AbstractJDOConfigTest.java
index 18877091..5a08f1e2 100644
--- a/api/src/test/java/javax/jdo/AbstractJDOConfigTest.java
+++ b/api/src/test/java/javax/jdo/AbstractJDOConfigTest.java
@@ -130,7 +130,7 @@ public abstract class AbstractJDOConfigTest extends AbstractTest {
                 SERVICE_LOOKUP_PMF_RESOURCE_NAME);
             while (urls.hasMoreElements()) {
                 // return the first one found
-                return JDOHelper.getClassNameFromURL((URL)urls.nextElement());
+                return JDOHelper.getClassNameFromURL(urls.nextElement());
             }
         } catch (Exception ex) {
             // ignore exceptions from i/o errors
diff --git a/api/src/test/java/javax/jdo/JDOHelperConfigTest.java b/api/src/test/java/javax/jdo/JDOHelperConfigTest.java
index a04e2485..5685e492 100644
--- a/api/src/test/java/javax/jdo/JDOHelperConfigTest.java
+++ b/api/src/test/java/javax/jdo/JDOHelperConfigTest.java
@@ -214,7 +214,7 @@ public class JDOHelperConfigTest extends AbstractJDOConfigTest implements Consta
             getClass().getClassLoader(), classpaths);
         Map<String, String> expected = prepareInitialExpectedMap(testVariantName,
             listenerCount, vendorSpecificPropertyCount, excludeName, excludePUName);
-        String name = testVariantName == null ? null : (String) expected.get(PROPERTY_NAME);
+        String name = testVariantName == null ? null : expected.get(PROPERTY_NAME);
         Map<Object, Object> actual = JDOHelper.getPropertiesFromJdoconfig(name, loader);
 
         assertNotNull("No properties found", actual);
diff --git a/api/src/test/java/javax/jdo/JDOHelperTest.java b/api/src/test/java/javax/jdo/JDOHelperTest.java
index 86edd3b9..0ca22f4a 100644
--- a/api/src/test/java/javax/jdo/JDOHelperTest.java
+++ b/api/src/test/java/javax/jdo/JDOHelperTest.java
@@ -296,7 +296,7 @@ public class JDOHelperTest extends AbstractTest {
      */
     public void testGetPMFNullJNDI() {
         try {
-            JDOHelper.getPersistenceManagerFactory((String)null, getInitialContext());
+            JDOHelper.getPersistenceManagerFactory(null, getInitialContext());
             fail("Null JNDI resource name should result in JDOFatalUserException");
         }
         catch (JDOFatalUserException ex) {
@@ -309,7 +309,7 @@ public class JDOHelperTest extends AbstractTest {
      */
     public void testGetPMFNullJNDIGoodClassLoader() {
         try {
-            JDOHelper.getPersistenceManagerFactory((String)null, getInitialContext(), this.getClass().getClassLoader());
+            JDOHelper.getPersistenceManagerFactory(null, getInitialContext(), this.getClass().getClassLoader());
             fail("Null JNDI resource name should result in JDOFatalUserException");
         }
         catch (JDOFatalUserException ex) {
@@ -387,7 +387,7 @@ public class JDOHelperTest extends AbstractTest {
      */
     public void testGetPMFBothNullClassLoader() {
         try {
-            JDOHelper.getPersistenceManagerFactory("Whatever", (ClassLoader)null, (ClassLoader)null);
+            JDOHelper.getPersistenceManagerFactory("Whatever", (ClassLoader)null, null);
             fail("Null ClassLoader should result in JDOFatalUserException");
         }
         catch (JDOFatalUserException ex) {
diff --git a/api/src/test/java/javax/jdo/PMFService.java b/api/src/test/java/javax/jdo/PMFService.java
index e1edb448..6b41cced 100644
--- a/api/src/test/java/javax/jdo/PMFService.java
+++ b/api/src/test/java/javax/jdo/PMFService.java
@@ -29,8 +29,7 @@ public class PMFService implements Constants{
 
     public static PersistenceManagerFactory getPersistenceManagerFactory(
             Map<?, ?> overrides, Map<?, ?> props) {
-        PersistenceManagerFactory pmf =
-                (PersistenceManagerFactory) PMFProxy.newInstance();
+        PersistenceManagerFactory pmf = PMFProxy.newInstance();
         setPMFProperties(pmf, props, overrides);
 
         return pmf;
@@ -38,8 +37,7 @@ public class PMFService implements Constants{
 
     public static PersistenceManagerFactory getPersistenceManagerFactory(
             Map<?, ?> props) {
-        PersistenceManagerFactory pmf =
-                (PersistenceManagerFactory) PMFProxy.newInstance();
+        PersistenceManagerFactory pmf = PMFProxy.newInstance();
         setPMFProperties(pmf, props, null);
 
         return pmf;
diff --git a/api/src/test/java/javax/jdo/identity/IntIdentityTest.java b/api/src/test/java/javax/jdo/identity/IntIdentityTest.java
index 271531e2..283b04a1 100644
--- a/api/src/test/java/javax/jdo/identity/IntIdentityTest.java
+++ b/api/src/test/java/javax/jdo/identity/IntIdentityTest.java
@@ -43,29 +43,29 @@ public class IntIdentityTest extends SingleFieldIdentityTest {
     }
     
     public void testConstructor() {
-        IntIdentity c1 = new IntIdentity(Object.class, (int)1);
-        IntIdentity c2 = new IntIdentity(Object.class, (int)1);
-        IntIdentity c3 = new IntIdentity(Object.class, (int)2);
+        IntIdentity c1 = new IntIdentity(Object.class, 1);
+        IntIdentity c2 = new IntIdentity(Object.class, 1);
+        IntIdentity c3 = new IntIdentity(Object.class, 2);
         assertEquals("Equal IntIdentity instances compare not equal.", c1, c2);
         assertFalse ("Not equal IntIdentity instances compare equal", c1.equals(c3));
     }
 
     public void testIntegerConstructor() {
-        IntIdentity c1 = new IntIdentity(Object.class, (int)1);
-        IntIdentity c2 = new IntIdentity(Object.class, Integer.valueOf((int)1));
-        IntIdentity c3 = new IntIdentity(Object.class, Integer.valueOf((int)2));
+        IntIdentity c1 = new IntIdentity(Object.class, 1);
+        IntIdentity c2 = new IntIdentity(Object.class, Integer.valueOf(1));
+        IntIdentity c3 = new IntIdentity(Object.class, Integer.valueOf(2));
         assertEquals ("Equal intIdentity instances compare not equal.", c1, c2);
         assertFalse ("Not equal IntIdentity instances compare equal", c1.equals(c3));
     }
 
     public void testToStringConstructor() {
-        IntIdentity c1 = new IntIdentity(Object.class, (int)1);
+        IntIdentity c1 = new IntIdentity(Object.class, 1);
         IntIdentity c2 = new IntIdentity(Object.class, c1.toString());
         assertEquals ("Equal IntIdentity instances compare not equal.", c1, c2);
     }
 
     public void testStringConstructor() {
-        IntIdentity c1 = new IntIdentity(Object.class, (int)1);
+        IntIdentity c1 = new IntIdentity(Object.class, 1);
         IntIdentity c2 = new IntIdentity(Object.class, "1");
         IntIdentity c3 = new IntIdentity(Object.class, "2");
         assertEquals ("Equal IntIdentity instances compare not equal.", c1, c2);
@@ -82,7 +82,7 @@ public class IntIdentityTest extends SingleFieldIdentityTest {
     }
     
     public void testSerialized() {
-        IntIdentity c1 = new IntIdentity(Object.class, (int)1);
+        IntIdentity c1 = new IntIdentity(Object.class, 1);
         IntIdentity c2 = new IntIdentity(Object.class, "1");
         IntIdentity c3 = new IntIdentity(Object.class, "2");
         Object[] scis = writeReadSerialized(new Object[] {c1, c2, c3});
diff --git a/api/src/test/java/javax/jdo/identity/ObjectIdentityTest.java b/api/src/test/java/javax/jdo/identity/ObjectIdentityTest.java
index af957726..ed07797a 100644
--- a/api/src/test/java/javax/jdo/identity/ObjectIdentityTest.java
+++ b/api/src/test/java/javax/jdo/identity/ObjectIdentityTest.java
@@ -52,7 +52,7 @@ public class ObjectIdentityTest extends SingleFieldIdentityTest {
     
     /** The JDOImplHelper instance used for Date formatting.
      */
-    private static JDOImplHelper helper = (JDOImplHelper)
+    private static JDOImplHelper helper =
         doPrivileged(
             new PrivilegedAction<JDOImplHelper> () {
                 public JDOImplHelper run () {
diff --git a/api/src/test/java/javax/jdo/util/XMLTestUtil.java b/api/src/test/java/javax/jdo/util/XMLTestUtil.java
index 8ed53e4b..07f5ce25 100644
--- a/api/src/test/java/javax/jdo/util/XMLTestUtil.java
+++ b/api/src/test/java/javax/jdo/util/XMLTestUtil.java
@@ -313,7 +313,7 @@ public class XMLTestUtil {
                     while (bufferedReader.ready()) {
                         tmp.add(bufferedReader.readLine());
                     }
-                    lines = (String[])tmp.toArray(new String[tmp.size()]);
+                    lines = tmp.toArray(new String[tmp.size()]);
                 } catch (IOException ex) {
                     throw new JDOFatalException("getLines: caught IOException", ex);
                 }
@@ -406,9 +406,9 @@ public class XMLTestUtil {
             throws SAXException, IOException 
         {
             // check for recognized ids
-            String filename = (String)publicIds.get(publicId);
+            String filename = publicIds.get(publicId);
             if (filename == null) {
-                filename = (String)systemIds.get(systemId);
+                filename = systemIds.get(systemId);
             }
             final String finalName = filename;
             if (finalName == null) {
@@ -503,7 +503,7 @@ public class XMLTestUtil {
 
         /** Returns an array of test files with suffix .jdo, .orm or .jdoquery. */
         public File[] getMetadataFiles() {
-            return (File[])metadataFiles.toArray(new File[metadataFiles.size()]);
+            return metadataFiles.toArray(new File[metadataFiles.size()]);
         }
 
     }
@@ -518,7 +518,7 @@ public class XMLTestUtil {
             while (st.hasMoreTokens()) {
                 entries.add(st.nextToken());
             }
-            ret = (String[])entries.toArray(new String[entries.size()]);
+            ret = entries.toArray(new String[entries.size()]);
         }
         return ret;
     }


[db-jdo] 07/07: JDO-817 removing compiler warnings: „anonymous can be replaced by lambda“ in api submodule

Posted by mb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mbo pushed a commit to branch tck-compiler-warnings
in repository https://gitbox.apache.org/repos/asf/db-jdo.git

commit 6084535ecbb99ccff46d30591827b09f21dc978c
Author: Michael Bouschen <Mi...@akquinet.de>
AuthorDate: Sat Aug 13 21:21:42 2022 +0200

    JDO-817 removing compiler warnings: „anonymous can be replaced by lambda“ in api submodule
---
 api/src/main/java/javax/jdo/JDOHelper.java         | 114 ++++-----------------
 .../java/javax/jdo/identity/ObjectIdentity.java    |   9 +-
 api/src/main/java/javax/jdo/spi/I18NHelper.java    |  16 +--
 api/src/main/java/javax/jdo/spi/JDOImplHelper.java |  51 ++++-----
 api/src/test/java/javax/jdo/EnhancerTest.java      |  22 ++--
 .../javax/jdo/identity/ObjectIdentityTest.java     |   9 +-
 api/src/test/java/javax/jdo/schema/XMLTest.java    |   6 +-
 api/src/test/java/javax/jdo/util/XMLTestUtil.java  |  12 +--
 8 files changed, 56 insertions(+), 183 deletions(-)

diff --git a/api/src/main/java/javax/jdo/JDOHelper.java b/api/src/main/java/javax/jdo/JDOHelper.java
index 3473be46..fb479b84 100644
--- a/api/src/main/java/javax/jdo/JDOHelper.java
+++ b/api/src/main/java/javax/jdo/JDOHelper.java
@@ -176,13 +176,7 @@ public class JDOHelper implements Constants {
      *  implementations.
      */
     private static JDOImplHelper implHelper =
-        doPrivileged(
-            new PrivilegedAction<JDOImplHelper> () {
-                public JDOImplHelper run () {
-                    return JDOImplHelper.getInstance();
-                }
-            }
-        );
+            doPrivileged((PrivilegedAction<JDOImplHelper>) JDOImplHelper::getInstance);
 
     /** The singleton instance of JDOHelper.
      * @since 2.1
@@ -209,101 +203,61 @@ public class JDOHelper implements Constants {
     *  implementations of getPersistenceManager.
     */
     static StateInterrogationObjectReturn getPersistenceManager =
-        new StateInterrogationObjectReturn() {
-            public Object get(Object pc, StateInterrogation si) {
-                return si.getPersistenceManager(pc);
-            }
-        };
+            (pc, si) -> si.getPersistenceManager(pc);
 
    /** The stateless instance used for handling non-binary-compatible
     *  implementations of getObjectId.
     */
     static StateInterrogationObjectReturn getObjectId =
-        new StateInterrogationObjectReturn() {
-            public Object get(Object pc, StateInterrogation si) {
-                return si.getObjectId(pc);
-            }
-        };
+           (pc, si) -> si.getObjectId(pc);
 
    /** The stateless instance used for handling non-binary-compatible
     *  implementations of getTransactionalObjectId.
     */
     static StateInterrogationObjectReturn getTransactionalObjectId =
-        new StateInterrogationObjectReturn() {
-            public Object get(Object pc, StateInterrogation si) {
-                return si.getTransactionalObjectId(pc);
-            }
-        };
+           (pc, si) -> si.getTransactionalObjectId(pc);
 
    /** The stateless instance used for handling non-binary-compatible
     *  implementations of getVersion.
     */
     static StateInterrogationObjectReturn getVersion =
-        new StateInterrogationObjectReturn() {
-            public Object get(Object pc, StateInterrogation si) {
-                return si.getVersion(pc);
-            }
-        };
+           (pc, si) -> si.getVersion(pc);
 
    /** The stateless instance used for handling non-binary-compatible
     *  implementations of isPersistent.
     */
     static StateInterrogationBooleanReturn isPersistent =
-        new StateInterrogationBooleanReturn() {
-            public Boolean is(Object pc, StateInterrogation si) {
-                return si.isPersistent(pc);
-            }
-        };
+           (pc, si) -> si.isPersistent(pc);
 
    /** The stateless instance used for handling non-binary-compatible
     *  implementations of isTransactional.
     */
     static StateInterrogationBooleanReturn isTransactional =
-        new StateInterrogationBooleanReturn() {
-            public Boolean is(Object pc, StateInterrogation si) {
-                return si.isTransactional(pc);
-            }
-        };
+           (pc, si) -> si.isTransactional(pc);
 
    /** The stateless instance used for handling non-binary-compatible
     *  implementations of isDirty.
     */
     static StateInterrogationBooleanReturn isDirty =
-        new StateInterrogationBooleanReturn() {
-            public Boolean is(Object pc, StateInterrogation si) {
-                return si.isDirty(pc);
-            }
-        };
+           (pc, si) -> si.isDirty(pc);
 
    /** The stateless instance used for handling non-binary-compatible
     *  implementations of isNew.
     */
     static StateInterrogationBooleanReturn isNew =
-        new StateInterrogationBooleanReturn() {
-            public Boolean is(Object pc, StateInterrogation si) {
-                return si.isNew(pc);
-            }
-        };
+           (pc, si) -> si.isNew(pc);
 
    /** The stateless instance used for handling non-binary-compatible
     *  implementations of isDeleted.
     */
     static StateInterrogationBooleanReturn isDeleted =
-        new StateInterrogationBooleanReturn() {
-            public Boolean is(Object pc, StateInterrogation si) {
-                return si.isDeleted(pc);
-            }
-        };
+           (pc, si) -> si.isDeleted(pc);
 
    /** The stateless instance used for handling non-binary-compatible
     *  implementations of isDetached.
     */
     static StateInterrogationBooleanReturn isDetached =
-        new StateInterrogationBooleanReturn() {
-            public Boolean is(Object pc, StateInterrogation si) {
-                return si.isDetached(pc);
-            }
-        };
+           (pc, si) -> si.isDetached(pc);
 
     /** Return the associated <code>PersistenceManager</code> if there is one.
      * Transactional and persistent instances return the associated
@@ -1902,11 +1856,7 @@ public class JDOHelper implements Constants {
      */
     private static ClassLoader getContextClassLoader() {
         return doPrivileged(
-            new PrivilegedAction<ClassLoader> () {
-                public ClassLoader run () {
-                    return Thread.currentThread().getContextClassLoader();
-                }
-            }
+                (PrivilegedAction<ClassLoader>) () -> Thread.currentThread().getContextClassLoader()
         );
     }
 
@@ -1915,13 +1865,7 @@ public class JDOHelper implements Constants {
      */
     private static InputStream getResourceAsStream(
             final ClassLoader resourceLoader, final String name) {
-        return doPrivileged(
-            new PrivilegedAction<InputStream>() {
-                public InputStream run() {
-                    return resourceLoader.getResourceAsStream(name);
-                }
-            }
-        );
+        return doPrivileged((PrivilegedAction<InputStream>) () -> resourceLoader.getResourceAsStream(name));
     }
 
 
@@ -1940,11 +1884,7 @@ public class JDOHelper implements Constants {
                 throws NoSuchMethodException {
         try {
             return doPrivileged(
-                new PrivilegedExceptionAction<Method>() {
-                    public Method run() throws NoSuchMethodException {
-                        return implClass.getMethod(methodName, parameterTypes);
-                    }
-                }
+                    (PrivilegedExceptionAction<Method>) () -> implClass.getMethod(methodName, parameterTypes)
             );
         } catch (PrivilegedActionException ex) {
             throw (NoSuchMethodException)ex.getException();
@@ -1959,13 +1899,7 @@ public class JDOHelper implements Constants {
                 throws IllegalAccessException, InvocationTargetException {
         try {
             return doPrivileged(
-                new PrivilegedExceptionAction<Object>() {
-                    public Object run() 
-                        throws IllegalAccessException, 
-                            InvocationTargetException {
-                        return method.invoke (instance, parameters);
-                    }
-                }
+                    (PrivilegedExceptionAction<Object>) () -> method.invoke (instance, parameters)
             );
         } catch (PrivilegedActionException ex) {
             Exception cause = ex.getException();
@@ -1990,11 +1924,7 @@ public class JDOHelper implements Constants {
                 throws IOException {
         try {
             return doPrivileged(
-                new PrivilegedExceptionAction<Enumeration<URL>>() {
-                    public Enumeration<URL> run() throws IOException {
-                        return resourceLoader.getResources(resourceName);
-                    }
-                }
+                    (PrivilegedExceptionAction<Enumeration<URL>>) () -> resourceLoader.getResources(resourceName)
             );
         } catch (PrivilegedActionException ex) {
             throw (IOException)ex.getException();
@@ -2016,11 +1946,7 @@ public class JDOHelper implements Constants {
                 throws ClassNotFoundException {
         try {
             return doPrivileged(
-                new PrivilegedExceptionAction<Class<?>>() {
-                    public Class<?> run() throws ClassNotFoundException {
-                        return Class.forName(name, init, loader);
-                    }
-                }
+                    (PrivilegedExceptionAction<Class<?>>) () -> Class.forName(name, init, loader)
             );
         } catch (PrivilegedActionException ex) {
             throw (ClassNotFoundException)ex.getException();
@@ -2037,11 +1963,7 @@ public class JDOHelper implements Constants {
             throws IOException {
         try {
             return doPrivileged(
-                new PrivilegedExceptionAction<InputStream>() {
-                    public InputStream run() throws IOException {
-                        return url.openStream();
-                    }
-                }
+                    (PrivilegedExceptionAction<InputStream>) () -> url.openStream()
             );
         } catch (PrivilegedActionException ex) {
             throw (IOException)ex.getException();
diff --git a/api/src/main/java/javax/jdo/identity/ObjectIdentity.java b/api/src/main/java/javax/jdo/identity/ObjectIdentity.java
index 6106d891..a3285842 100644
--- a/api/src/main/java/javax/jdo/identity/ObjectIdentity.java
+++ b/api/src/main/java/javax/jdo/identity/ObjectIdentity.java
@@ -47,14 +47,7 @@ public class ObjectIdentity extends SingleFieldIdentity<ObjectIdentity> {
     
     /** The JDOImplHelper instance used for parsing the String to an Object.
      */
-    private static JDOImplHelper helper =
-        doPrivileged(
-            new PrivilegedAction<JDOImplHelper> () {
-                public JDOImplHelper run () {
-                    return JDOImplHelper.getInstance();
-                }
-            }
-        );
+    private static JDOImplHelper helper = doPrivileged(JDOImplHelper::getInstance);
 
     @SuppressWarnings("unchecked")
     private static <T> T doPrivileged(PrivilegedAction<T> privilegedAction) {
diff --git a/api/src/main/java/javax/jdo/spi/I18NHelper.java b/api/src/main/java/javax/jdo/spi/I18NHelper.java
index 161bf844..304e082b 100644
--- a/api/src/main/java/javax/jdo/spi/I18NHelper.java
+++ b/api/src/main/java/javax/jdo/spi/I18NHelper.java
@@ -106,13 +106,7 @@ public class I18NHelper {
      * @return the helper instance bound to the bundle
      */
     public static I18NHelper getInstance (final Class<?> cls) {
-        ClassLoader classLoader = doPrivileged (
-            new PrivilegedAction<ClassLoader> () {
-                public ClassLoader run () {
-                    return cls.getClassLoader();
-                }
-            }
-            );
+        ClassLoader classLoader = doPrivileged (cls::getClassLoader);
         String bundle = getPackageName (cls.getName()) + bundleSuffix;
         return getInstance (bundle, classLoader);
     }
@@ -388,13 +382,7 @@ public class I18NHelper {
      * block because of security.
      */
     private static ClassLoader getSystemClassLoaderPrivileged() {
-        return doPrivileged (
-            new PrivilegedAction<ClassLoader> () {
-                public ClassLoader run () {
-                    return ClassLoader.getSystemClassLoader();
-                }
-            }
-        );
+        return doPrivileged (ClassLoader::getSystemClassLoader);
     }
 
     @SuppressWarnings("unchecked")
diff --git a/api/src/main/java/javax/jdo/spi/JDOImplHelper.java b/api/src/main/java/javax/jdo/spi/JDOImplHelper.java
index b036c9bf..b1cd91e7 100644
--- a/api/src/main/java/javax/jdo/spi/JDOImplHelper.java
+++ b/api/src/main/java/javax/jdo/spi/JDOImplHelper.java
@@ -736,30 +736,27 @@ public class JDOImplHelper extends java.lang.Object {
     static {
         if (isClassLoadable("java.util.Currency")) {
             jdoImplHelper.registerStringConstructor(
-                    Currency.class, new StringConstructor() {
-                public Object construct(String s) {
-                    try {
-                        return Currency.getInstance(s);
-                    } catch (IllegalArgumentException ex) {
-                        throw new javax.jdo.JDOUserException(msg.msg(
-                            "EXC_CurrencyStringConstructorIllegalArgument", //NOI18N
-                            s), ex); 
-                    } catch (Exception ex) {
-                        throw new JDOUserException(msg.msg(
-                            "EXC_CurrencyStringConstructorException"), //NOI18N
-                            ex); 
-                    }
-                }
-            });
+                    Currency.class,
+                    s -> {
+                        try {
+                            return Currency.getInstance(s);
+                        } catch (IllegalArgumentException ex) {
+                            throw new JDOUserException(msg.msg(
+                                "EXC_CurrencyStringConstructorIllegalArgument", //NOI18N
+                                s), ex);
+                        } catch (Exception ex) {
+                            throw new JDOUserException(msg.msg(
+                                "EXC_CurrencyStringConstructorException"), //NOI18N
+                                ex);
+                        }
+                    });
         }
-        jdoImplHelper.registerStringConstructor(Locale.class, new StringConstructor() {
-            public Object construct(String s) {
-                try {
-                    return getLocale(s);
-                } catch (Exception ex) {
-                    throw new JDOUserException(msg.msg(
-                        "EXC_LocaleStringConstructorException"), ex); //NOI18N
-                }
+        jdoImplHelper.registerStringConstructor(Locale.class, s -> {
+            try {
+                return getLocale(s);
+            } catch (Exception ex) {
+                throw new JDOUserException(msg.msg(
+                    "EXC_LocaleStringConstructorException"), ex); //NOI18N
             }
         });
         jdoImplHelper.registerStringConstructor(Date.class, new StringConstructor() {
@@ -874,13 +871,7 @@ public class JDOImplHelper extends java.lang.Object {
     static DateFormat getDateTimeInstance() {
         DateFormat result = null;
         try {
-        result = doPrivileged (
-            new PrivilegedAction<DateFormat> () {
-                public DateFormat run () {
-                    return DateFormat.getDateTimeInstance();
-                }
-            }
-            );
+        result = doPrivileged (() -> DateFormat.getDateTimeInstance());
         } catch (Exception ex) {
             result = DateFormat.getInstance();
         }
diff --git a/api/src/test/java/javax/jdo/EnhancerTest.java b/api/src/test/java/javax/jdo/EnhancerTest.java
index 38782e95..4e8046c1 100644
--- a/api/src/test/java/javax/jdo/EnhancerTest.java
+++ b/api/src/test/java/javax/jdo/EnhancerTest.java
@@ -324,19 +324,17 @@ public class EnhancerTest extends AbstractTest {
     private Thread createReaderThread(final InputStream input, final CharBuffer output) {
         final Reader reader = new InputStreamReader(input);
         Thread thread = new Thread(
-                new Runnable() {
-                    public void run() {
-                        int count = 0;
-                        int outputBytesRead = 0;
-                        try {
-                            while (-1 != (outputBytesRead = reader.read(output))) {
-                                count += outputBytesRead;
-                            }
-                        } catch (IOException e) {
-                            e.printStackTrace();
-                        } finally {
-                            output.flip();
+                () -> {
+                    int count = 0;
+                    int outputBytesRead = 0;
+                    try {
+                        while (-1 != (outputBytesRead = reader.read(output))) {
+                            count += outputBytesRead;
                         }
+                    } catch (IOException e) {
+                        e.printStackTrace();
+                    } finally {
+                        output.flip();
                     }
                 });
         thread.start();
diff --git a/api/src/test/java/javax/jdo/identity/ObjectIdentityTest.java b/api/src/test/java/javax/jdo/identity/ObjectIdentityTest.java
index 63d311f4..34af5cf7 100644
--- a/api/src/test/java/javax/jdo/identity/ObjectIdentityTest.java
+++ b/api/src/test/java/javax/jdo/identity/ObjectIdentityTest.java
@@ -52,14 +52,7 @@ public class ObjectIdentityTest extends SingleFieldIdentityTest {
     
     /** The JDOImplHelper instance used for Date formatting.
      */
-    private static JDOImplHelper helper =
-        doPrivileged(
-            new PrivilegedAction<JDOImplHelper> () {
-                public JDOImplHelper run () {
-                    return JDOImplHelper.getInstance();
-                }
-            }
-        );
+    private static JDOImplHelper helper = doPrivileged(JDOImplHelper::getInstance);
 
     @SuppressWarnings("unchecked")
     private static <T> T doPrivileged(PrivilegedAction<T> privilegedAction) {
diff --git a/api/src/test/java/javax/jdo/schema/XMLTest.java b/api/src/test/java/javax/jdo/schema/XMLTest.java
index ceb03e47..c1286952 100644
--- a/api/src/test/java/javax/jdo/schema/XMLTest.java
+++ b/api/src/test/java/javax/jdo/schema/XMLTest.java
@@ -70,11 +70,7 @@ public class XMLTest extends AbstractTest {
     
     /** Returns array of files of matching file names. */
     protected static File[] getFiles(final String prefix, final String suffix) {
-        FilenameFilter filter = new FilenameFilter () {
-            public boolean accept(File file, String name) {
-                return (name.startsWith(prefix) && name.endsWith(suffix));
-            }
-        };
+        FilenameFilter filter = (file, name) -> (name.startsWith(prefix) && name.endsWith(suffix));
         File dir = new File(FILE_PREFIX);
         return dir.listFiles(filter);
     }
diff --git a/api/src/test/java/javax/jdo/util/XMLTestUtil.java b/api/src/test/java/javax/jdo/util/XMLTestUtil.java
index 07f5ce25..520c8926 100644
--- a/api/src/test/java/javax/jdo/util/XMLTestUtil.java
+++ b/api/src/test/java/javax/jdo/util/XMLTestUtil.java
@@ -456,21 +456,13 @@ public class XMLTestUtil {
         
         /** Returns array of files of matching file names. */
         private File[] getFiles(File dir, final String suffix) {
-            FilenameFilter filter = new FilenameFilter() {
-                    public boolean accept(File file, String name) {
-                        return name.endsWith(suffix);
-                    }
-                };
+            FilenameFilter filter = (file, name) -> name.endsWith(suffix);
             return dir.listFiles(filter);
         }
 
         /** */
         private File[] getDirectories(File dir) {
-            FileFilter filter = new FileFilter() {
-                    public boolean accept(File pathname) {
-                        return pathname.isDirectory();
-                    }
-                };
+            FileFilter filter = File::isDirectory;
             return dir.listFiles(filter);
         }
 


[db-jdo] 06/07: JDO-817 removing compiler warnings: „while loop replaceable with enhanced for loop“ in api submodule

Posted by mb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mbo pushed a commit to branch tck-compiler-warnings
in repository https://gitbox.apache.org/repos/asf/db-jdo.git

commit 7f1ea28478fa4ba203beae6cc410ef7c0736e049
Author: Michael Bouschen <Mi...@akquinet.de>
AuthorDate: Sat Aug 13 21:08:03 2022 +0200

    JDO-817 removing compiler warnings: „while loop replaceable with enhanced for loop“ in api submodule
---
 api/src/main/java/javax/jdo/Enhancer.java              |  8 +++-----
 api/src/main/java/javax/jdo/JDOHelper.java             | 16 +++++++---------
 api/src/test/java/javax/jdo/AbstractJDOConfigTest.java |  4 +---
 3 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/api/src/main/java/javax/jdo/Enhancer.java b/api/src/main/java/javax/jdo/Enhancer.java
index d1edb1f1..dfcf6d96 100644
--- a/api/src/main/java/javax/jdo/Enhancer.java
+++ b/api/src/main/java/javax/jdo/Enhancer.java
@@ -154,13 +154,11 @@ public class Enhancer {
             addVerboseMessage("MSG_EnhancerProperty", PROPERTY_ENHANCER_VERSION_NUMBER, //NOI18N
                     properties.getProperty(PROPERTY_ENHANCER_VERSION_NUMBER));
             Set<Entry<Object, Object>> props = properties.entrySet();
-            Iterator<Entry<Object, Object>> entries = props.iterator();
-            while (entries.hasNext()) {
-                Entry<Object, Object> entry = entries.next();
+            for (Entry<Object, Object> entry : props) {
                 if (!(PROPERTY_ENHANCER_VENDOR_NAME.equals(entry.getKey()) ||
                         PROPERTY_ENHANCER_VERSION_NUMBER.equals(entry.getKey()))) {
-                    addVerboseMessage("MSG_EnhancerProperty", (String)entry.getKey(), //NOI18N
-                            (String)entry.getValue());                    
+                    addVerboseMessage("MSG_EnhancerProperty", (String) entry.getKey(), //NOI18N
+                            (String) entry.getValue());
                 }
             }
             enhancer.setVerbose(verbose);
diff --git a/api/src/main/java/javax/jdo/JDOHelper.java b/api/src/main/java/javax/jdo/JDOHelper.java
index 6dbcc4fe..3473be46 100644
--- a/api/src/main/java/javax/jdo/JDOHelper.java
+++ b/api/src/main/java/javax/jdo/JDOHelper.java
@@ -1472,17 +1472,15 @@ public class JDOHelper implements Constants {
 
                 // check for duplicate properties among atts & elems
                 if (requestedPMFName.equals(pmfName)) {
-                    Iterator<?> it =
-                        pmfPropertiesFromAttributes.keySet().iterator();
-                    while (it.hasNext()) {
-                        String property = (String) it.next();
+                    for (Object o : pmfPropertiesFromAttributes.keySet()) {
+                        String property = (String) o;
                         if (pmfPropertiesFromElements.contains(property)) {
                             throw new JDOFatalUserException(
-                                msg.msg(
-                                    "EXC_DuplicatePropertyFound",
-                                    property,
-                                    pmfName,
-                                    url.toExternalForm()));
+                                    msg.msg(
+                                            "EXC_DuplicatePropertyFound",
+                                            property,
+                                            pmfName,
+                                            url.toExternalForm()));
                         }
                     }
                 }
diff --git a/api/src/test/java/javax/jdo/AbstractJDOConfigTest.java b/api/src/test/java/javax/jdo/AbstractJDOConfigTest.java
index 5a08f1e2..0a25fe45 100644
--- a/api/src/test/java/javax/jdo/AbstractJDOConfigTest.java
+++ b/api/src/test/java/javax/jdo/AbstractJDOConfigTest.java
@@ -109,9 +109,7 @@ public abstract class AbstractJDOConfigTest extends AbstractTest {
      * @param actual the second {@link java.util.Map Map} object to test.
      */
     static void assertEqualProperties(Map<?, ?> expected, Map<?, ?> actual) {
-        Iterator<? extends Map.Entry<?, ?>> i = expected.entrySet().iterator();
-        while (i.hasNext()) {
-            Map.Entry<?, ?> entry = i.next();
+        for (Map.Entry<?, ?> entry : expected.entrySet()) {
             String key = (String) entry.getKey();
             String expectedValue = (String) entry.getValue();
             String actualValue = (String) actual.get(key);


[db-jdo] 03/07: JDO-817 removing compiler warnings: "raw use of parameterized class" in api submodule

Posted by mb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mbo pushed a commit to branch tck-compiler-warnings
in repository https://gitbox.apache.org/repos/asf/db-jdo.git

commit 38048f5dc28a332ec00a59c3970eb84a2a38389a
Author: Michael Bouschen <Mi...@akquinet.de>
AuthorDate: Sat Aug 13 20:50:55 2022 +0200

    JDO-817 removing compiler warnings: "raw use of parameterized class" in api submodule
---
 api/src/main/java/javax/jdo/annotations/Element.java           | 2 +-
 api/src/main/java/javax/jdo/annotations/Key.java               | 2 +-
 api/src/main/java/javax/jdo/annotations/Persistent.java        | 2 +-
 api/src/main/java/javax/jdo/annotations/Value.java             | 2 +-
 api/src/main/java/javax/jdo/identity/SingleFieldIdentity.java  | 4 ++--
 api/src/test/java/javax/jdo/identity/ConcreteTestIdentity.java | 6 +++---
 api/src/test/java/javax/jdo/identity/ObjectIdentityTest.java   | 8 ++++----
 7 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/api/src/main/java/javax/jdo/annotations/Element.java b/api/src/main/java/javax/jdo/annotations/Element.java
index 1c9d2a30..3072e756 100644
--- a/api/src/main/java/javax/jdo/annotations/Element.java
+++ b/api/src/main/java/javax/jdo/annotations/Element.java
@@ -41,7 +41,7 @@ public @interface Element
      * implementation supports multiple types.
      * @return the types of elements
      */
-    Class[] types() default {};
+    Class<?>[] types() default {};
 
     /**
      * Whether the element is to be stored serialized (into a join table)
diff --git a/api/src/main/java/javax/jdo/annotations/Key.java b/api/src/main/java/javax/jdo/annotations/Key.java
index 2af27b87..8bb2ad7d 100644
--- a/api/src/main/java/javax/jdo/annotations/Key.java
+++ b/api/src/main/java/javax/jdo/annotations/Key.java
@@ -41,7 +41,7 @@ public @interface Key
      * implementation supports multiple types.
      * @return the types of keys
      */
-    Class[] types() default {};
+    Class<?>[] types() default {};
 
     /**
      * Whether the key is to be stored serialized (into a single column of a
diff --git a/api/src/main/java/javax/jdo/annotations/Persistent.java b/api/src/main/java/javax/jdo/annotations/Persistent.java
index 70b975b2..acdcb46b 100644
--- a/api/src/main/java/javax/jdo/annotations/Persistent.java
+++ b/api/src/main/java/javax/jdo/annotations/Persistent.java
@@ -163,7 +163,7 @@ public @interface Persistent
      * for persistence.
      * @return the types
      */
-    Class[] types() default {};
+    Class<?>[] types() default {};
 
     /** Name of the related member in the other class 
      * where this value is mapped (bidirectional relationship). 
diff --git a/api/src/main/java/javax/jdo/annotations/Value.java b/api/src/main/java/javax/jdo/annotations/Value.java
index c56da16d..e2348cf2 100644
--- a/api/src/main/java/javax/jdo/annotations/Value.java
+++ b/api/src/main/java/javax/jdo/annotations/Value.java
@@ -41,7 +41,7 @@ public @interface Value
      * implementation supports multiple types.
      * @return the types of values
      */
-    Class[] types() default {};
+    Class<?>[] types() default {};
 
     /**
      * Whether the value  is to be stored serialized (into a single column of a
diff --git a/api/src/main/java/javax/jdo/identity/SingleFieldIdentity.java b/api/src/main/java/javax/jdo/identity/SingleFieldIdentity.java
index 7d23172b..981bc71d 100644
--- a/api/src/main/java/javax/jdo/identity/SingleFieldIdentity.java
+++ b/api/src/main/java/javax/jdo/identity/SingleFieldIdentity.java
@@ -151,7 +151,7 @@ public abstract class SingleFieldIdentity<SUBCLASS extends SingleFieldIdentity<S
         } else if (obj == null || this.getClass() != obj.getClass()) {
             return false;
         } else {
-            SingleFieldIdentity other = (SingleFieldIdentity) obj;
+            SingleFieldIdentity<?> other = (SingleFieldIdentity<?>) obj;
             if (targetClass != null && targetClass == other.targetClass)
                 return true;
             return targetClassName.equals (other.targetClassName);
@@ -197,7 +197,7 @@ public abstract class SingleFieldIdentity<SUBCLASS extends SingleFieldIdentity<S
      * @return The relative ordering between the objects
      * @since 2.2
      */
-    protected int compare(SingleFieldIdentity o) {
+    protected int compare(SingleFieldIdentity<?> o) {
             return targetClassName.compareTo(o.targetClassName);
         }
  
diff --git a/api/src/test/java/javax/jdo/identity/ConcreteTestIdentity.java b/api/src/test/java/javax/jdo/identity/ConcreteTestIdentity.java
index abbb72c2..52e5e0f6 100644
--- a/api/src/test/java/javax/jdo/identity/ConcreteTestIdentity.java
+++ b/api/src/test/java/javax/jdo/identity/ConcreteTestIdentity.java
@@ -30,7 +30,7 @@ import java.io.ObjectOutput;
  *
  * @author clr
  */
-    public class ConcreteTestIdentity extends SingleFieldIdentity {
+    public class ConcreteTestIdentity extends SingleFieldIdentity<ConcreteTestIdentity> {
 
         private static final long serialVersionUID = 1L;
 
@@ -49,8 +49,8 @@ import java.io.ObjectOutput;
          * @return The relative ordering between the objects
          * @since 2.2
          */
-        public int compareTo(Object o) {
-            throw new ClassCastException("Not implemented");
+        public int compareTo(ConcreteTestIdentity o) {
+            throw new UnsupportedOperationException("Not implemented");
         }
 
         public void writeExternal(ObjectOutput out) throws IOException {
diff --git a/api/src/test/java/javax/jdo/identity/ObjectIdentityTest.java b/api/src/test/java/javax/jdo/identity/ObjectIdentityTest.java
index ed07797a..63d311f4 100644
--- a/api/src/test/java/javax/jdo/identity/ObjectIdentityTest.java
+++ b/api/src/test/java/javax/jdo/identity/ObjectIdentityTest.java
@@ -268,25 +268,25 @@ public class ObjectIdentityTest extends SingleFieldIdentityTest {
 
     public void testStringLocaleConstructorLanguage() {
         if (!isClassLoadable("java.util.Currency")) return;
-        SingleFieldIdentity c1 = new ObjectIdentity(Object.class, 
+        SingleFieldIdentity<ObjectIdentity> c1 = new ObjectIdentity(Object.class,
                     "java.util.Locale:en");
         assertEquals(new Locale("en"), c1.getKeyAsObject());
     }
 
     public void testStringLocaleConstructorCountry() {
-        SingleFieldIdentity c1 = new ObjectIdentity(Object.class, 
+        SingleFieldIdentity<ObjectIdentity> c1 = new ObjectIdentity(Object.class,
                     "java.util.Locale:_US");
         assertEquals(new Locale("","US"), c1.getKeyAsObject());
     }
 
     public void testStringLocaleConstructorLanguageCountry() {
-        SingleFieldIdentity c1 = new ObjectIdentity(Object.class, 
+        SingleFieldIdentity<ObjectIdentity> c1 = new ObjectIdentity(Object.class,
                     "java.util.Locale:en_US");
         assertEquals(new Locale("en","US"), c1.getKeyAsObject());
     }
 
     public void testStringLocaleConstructorLanguageCountryVariant() {
-        SingleFieldIdentity c1 = new ObjectIdentity(Object.class, 
+        SingleFieldIdentity<ObjectIdentity> c1 = new ObjectIdentity(Object.class,
                     "java.util.Locale:en_US_MAC");
         assertEquals(new Locale("en","US","MAC"), c1.getKeyAsObject());
     }


[db-jdo] 04/07: JDO-817 removing compiler warnings: "raw use of parameterized class" in api submodule

Posted by mb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

mbo pushed a commit to branch tck-compiler-warnings
in repository https://gitbox.apache.org/repos/asf/db-jdo.git

commit 7ca32adb859ddf6d1247086f987cf0d943f75b47
Author: Michael Bouschen <Mi...@akquinet.de>
AuthorDate: Sat Aug 13 20:56:01 2022 +0200

    JDO-817 removing compiler warnings: "raw use of parameterized class" in api submodule
---
 api/src/test/java/javax/jdo/stub/StubPMF.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/api/src/test/java/javax/jdo/stub/StubPMF.java b/api/src/test/java/javax/jdo/stub/StubPMF.java
index f45ec139..dadfbc7e 100644
--- a/api/src/test/java/javax/jdo/stub/StubPMF.java
+++ b/api/src/test/java/javax/jdo/stub/StubPMF.java
@@ -405,7 +405,7 @@ public class StubPMF implements PersistenceManagerFactory, Constants {
     }
 
     @SuppressWarnings("rawtypes")
-    public Set getFetchGroups() {
+    public Set<FetchGroup> getFetchGroups() {
         throw new UnsupportedOperationException("not implemented");
     }