db-jdo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c..@apache.org
Subject svn commit: r723901 - in /db/jdo/trunk/api2/src/java/javax/jdo: JDOHelper.java identity/ObjectIdentity.java spi/I18NHelper.java spi/JDOImplHelper.java
Date Fri, 05 Dec 2008 22:20:55 GMT
Author: clr
Date: Fri Dec  5 14:20:54 2008
New Revision: 723901

URL: http://svn.apache.org/viewvc?rev=723901&view=rev
Log:
fix Java 5 unchecked call warnings

Modified:
    db/jdo/trunk/api2/src/java/javax/jdo/JDOHelper.java
    db/jdo/trunk/api2/src/java/javax/jdo/identity/ObjectIdentity.java
    db/jdo/trunk/api2/src/java/javax/jdo/spi/I18NHelper.java
    db/jdo/trunk/api2/src/java/javax/jdo/spi/JDOImplHelper.java

Modified: db/jdo/trunk/api2/src/java/javax/jdo/JDOHelper.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/api2/src/java/javax/jdo/JDOHelper.java?rev=723901&r1=723900&r2=723901&view=diff
==============================================================================
--- db/jdo/trunk/api2/src/java/javax/jdo/JDOHelper.java (original)
+++ db/jdo/trunk/api2/src/java/javax/jdo/JDOHelper.java Fri Dec  5 14:20:54 2008
@@ -103,7 +103,7 @@
      * properties.
      */
     static Map createAttributePropertyXref() {
-        Map xref = new HashMap();
+        Map<String,String> xref = new HashMap<String,String>();
 
         xref.put(
             PMF_ATTRIBUTE_CLASS,
@@ -171,8 +171,8 @@
      */
     private static JDOImplHelper implHelper = (JDOImplHelper)
         AccessController.doPrivileged(
-            new PrivilegedAction () {
-                public Object run () {
+            new PrivilegedAction<JDOImplHelper> () {
+                public JDOImplHelper run () {
                     return JDOImplHelper.getInstance();
                 }
             }
@@ -391,8 +391,8 @@
      * @see #getObjectIds(Object[] pcs)
      * @since 2.0
      */
-    public static Collection getObjectIds(Collection pcs) {
-        ArrayList result = new ArrayList();
+    public static Collection<Object> getObjectIds(Collection<Object> pcs) {
+        ArrayList<Object> result = new ArrayList<Object>();
         for (Iterator it = pcs.iterator(); it.hasNext();) {
             result.add(getObjectId(it.next()));
         }
@@ -786,7 +786,7 @@
      */
     protected static PersistenceManagerFactory getPersistenceManagerFactory
             (Map overrides, Map props, ClassLoader pmfClassLoader) {
-        List exceptions = new ArrayList();
+        List<Throwable> exceptions = new ArrayList<Throwable>();
         if (pmfClassLoader == null)
             throw new JDOFatalUserException (msg.msg (
                 "EXC_GetPMFNullLoader")); //NOI18N
@@ -1057,7 +1057,7 @@
                 "EXC_GetPMFNullPropsLoader")); //NOI18N
         }
 
-        Map props = null;
+        Map<Object,Object> props = null;
         // trim spaces from name and ensure non-null
         name = (name == null?ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME:name.trim());
         if (!ANONYMOUS_PERSISTENCE_MANAGER_FACTORY_NAME.equals(name)) {
@@ -1192,7 +1192,7 @@
      * @param name the name of the resource
      * @return a Properties instance or null if no resource is found
      */
-    protected static Map loadPropertiesFromResource(
+    protected static Map<Object,Object> loadPropertiesFromResource(
             ClassLoader resourceLoader, String name) {
         InputStream in = null;
         Properties props = null;
@@ -1223,7 +1223,7 @@
      * @see #getNamedPMFProperties(String,ClassLoader,String)
      * @since 2.1
      */
-    protected static Map getPropertiesFromJdoconfig(
+    protected static Map<Object,Object> getPropertiesFromJdoconfig(
             String name,
             ClassLoader resourceLoader) {
         return getNamedPMFProperties(
@@ -1252,27 +1252,27 @@
      * @throws JDOFatalUserException if multiple named PMF property sets are
      * found with the given name, or any other exception is encountered.
      */
-    protected static Map getNamedPMFProperties(
+    protected static Map<Object,Object> getNamedPMFProperties(
             String name,
             ClassLoader resourceLoader,
             String jdoconfigResourceName) {
         // key is PU name, value is Map of PU properties
-        Map/*<String,Map>*/ propertiesByNameInAllConfigs
-                = new HashMap/*<String,Map>*/();
+        Map<String,Map<Object,Object>> propertiesByNameInAllConfigs
+                = new HashMap<String,Map<Object,Object>>();
         try {
             URL firstFoundConfigURL = null;
 
             // get all JDO configurations
-            Enumeration resources =
+            Enumeration<URL> resources =
                 getResources(resourceLoader, jdoconfigResourceName);
 
             if (resources.hasMoreElements()) {
-                ArrayList processedResources = new ArrayList();
+                ArrayList<URL> processedResources = new ArrayList<URL>();
 
                 // get ready to parse XML
                 DocumentBuilderFactory factory = getDocumentBuilderFactory();
                 do {
-                    URL currentConfigURL = (URL) resources.nextElement();
+                    URL currentConfigURL = resources.nextElement();
                     if (processedResources.contains(currentConfigURL)) {
                         continue;
                     }
@@ -1280,7 +1280,7 @@
                         processedResources.add(currentConfigURL);
                     }
                     
-                    Map/*<String,Map>*/ propertiesByNameInCurrentConfig =
+                    Map<String,Map<Object,Object>> propertiesByNameInCurrentConfig
=
                         readNamedPMFProperties(
                             currentConfigURL,
                             name,
@@ -1319,11 +1319,12 @@
 
         // done with reading all config resources;
         // return what we found, which may very well be null
-        return (Map) propertiesByNameInAllConfigs.get(name);
+        return (Map<Object,Object>) propertiesByNameInAllConfigs.get(name);
     }
 
 
     protected static DocumentBuilderFactory getDocumentBuilderFactory() {
+        @SuppressWarnings("static-access")
         DocumentBuilderFactory factory =
                 implHelper.getRegisteredDocumentBuilderFactory();
         if (factory == null) {
@@ -1344,6 +1345,7 @@
     }
 
     protected static ErrorHandler getErrorHandler() {
+        @SuppressWarnings("static-access")
         ErrorHandler handler = implHelper.getRegisteredErrorHandler();
         if (handler == null) {
             handler = getDefaultErrorHandler();
@@ -1383,7 +1385,7 @@
      * the anonymous persistence unit, the
      * value of the String key is the empty string, "".
      */
-    protected static Map/*<String,Map>*/ readNamedPMFProperties(
+    protected static Map<String,Map<Object,Object>> readNamedPMFProperties(
             URL url,
             String requestedPMFName,
             DocumentBuilderFactory factory) {
@@ -1391,7 +1393,8 @@
             ? ""
             : requestedPMFName.trim();
 
-        Map propertiesByName = new HashMap();
+        Map<String,Map<Object,Object>>
+                propertiesByName = new HashMap<String,Map<Object,Object>>();
         InputStream in = null;
         try {
             DocumentBuilder builder = factory.newDocumentBuilder();
@@ -1856,7 +1859,7 @@
     	 * the invocation returns an instance.
     	 * Otherwise add the exception thrown to an exception list.
     	 */
-    	ArrayList exceptions = new ArrayList();
+    	ArrayList<Throwable> exceptions = new ArrayList<Throwable>();
     	try {
     		Enumeration urls = getResources(loader, SERVICE_LOOKUP_ENHANCER_RESOURCE_NAME);
         	if (urls != null) {
@@ -1886,9 +1889,9 @@
      * @since 2.0
      */
     private static ClassLoader getContextClassLoader() {
-        return (ClassLoader)AccessController.doPrivileged(
-            new PrivilegedAction () {
-                public Object run () {
+        return AccessController.doPrivileged(
+            new PrivilegedAction<ClassLoader> () {
+                public ClassLoader run () {
                     return Thread.currentThread().getContextClassLoader();
                 }
             }
@@ -1900,9 +1903,9 @@
      */
     private static InputStream getResourceAsStream(
             final ClassLoader resourceLoader, final String name) {
-        return (InputStream)AccessController.doPrivileged(
-            new PrivilegedAction() {
-                public Object run() {
+        return AccessController.doPrivileged(
+            new PrivilegedAction<InputStream>() {
+                public InputStream run() {
                     return resourceLoader.getResourceAsStream(name);
                 }
             }
@@ -1924,9 +1927,9 @@
             final Class[] parameterTypes) 
                 throws NoSuchMethodException {
         try {
-            return (Method) AccessController.doPrivileged(
-                new PrivilegedExceptionAction() {
-                    public Object run() throws NoSuchMethodException {
+            return AccessController.doPrivileged(
+                new PrivilegedExceptionAction<Method>() {
+                    public Method run() throws NoSuchMethodException {
                         return implClass.getMethod(methodName, parameterTypes);
                     }
                 }
@@ -1944,7 +1947,7 @@
                 throws IllegalAccessException, InvocationTargetException {
         try {
             return (Object) AccessController.doPrivileged(
-                new PrivilegedExceptionAction() {
+                new PrivilegedExceptionAction<Object>() {
                     public Object run() 
                         throws IllegalAccessException, 
                             InvocationTargetException {
@@ -1967,14 +1970,14 @@
      * @param resourceName
      * @return the resources
      */
-    protected static Enumeration getResources(
+    protected static Enumeration<URL> getResources(
             final ClassLoader resourceLoader, 
             final String resourceName) 
                 throws IOException {
         try {
-            return (Enumeration) AccessController.doPrivileged(
-                new PrivilegedExceptionAction() {
-                    public Object run() throws IOException {
+            return AccessController.doPrivileged(
+                new PrivilegedExceptionAction<Enumeration<URL>>() {
+                    public Enumeration<URL> run() throws IOException {
                         return resourceLoader.getResources(resourceName);
                     }
                 }
@@ -1998,9 +2001,9 @@
             final ClassLoader loader) 
                 throws ClassNotFoundException {
         try {
-            return (Class) AccessController.doPrivileged(
-                new PrivilegedExceptionAction() {
-                    public Object run() throws ClassNotFoundException {
+            return AccessController.doPrivileged(
+                new PrivilegedExceptionAction<Class>() {
+                    public Class run() throws ClassNotFoundException {
                         return Class.forName(name, init, loader);
                     }
                 }
@@ -2019,9 +2022,9 @@
     private static InputStream openStream(final URL url) 
             throws IOException {
         try {
-            return (InputStream) AccessController.doPrivileged(
-                new PrivilegedExceptionAction() {
-                    public Object run() throws IOException {
+            return AccessController.doPrivileged(
+                new PrivilegedExceptionAction<InputStream>() {
+                    public InputStream run() throws IOException {
                         return url.openStream();
                     }
                 }

Modified: db/jdo/trunk/api2/src/java/javax/jdo/identity/ObjectIdentity.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/api2/src/java/javax/jdo/identity/ObjectIdentity.java?rev=723901&r1=723900&r2=723901&view=diff
==============================================================================
--- db/jdo/trunk/api2/src/java/javax/jdo/identity/ObjectIdentity.java (original)
+++ db/jdo/trunk/api2/src/java/javax/jdo/identity/ObjectIdentity.java Fri Dec  5 14:20:54
2008
@@ -45,8 +45,8 @@
      */
     private static JDOImplHelper helper = (JDOImplHelper)
         AccessController.doPrivileged(
-            new PrivilegedAction () {
-                public Object run () {
+            new PrivilegedAction<JDOImplHelper> () {
+                public JDOImplHelper run () {
                     return JDOImplHelper.getInstance();
                 }
             }

Modified: db/jdo/trunk/api2/src/java/javax/jdo/spi/I18NHelper.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/api2/src/java/javax/jdo/spi/I18NHelper.java?rev=723901&r1=723900&r2=723901&view=diff
==============================================================================
--- db/jdo/trunk/api2/src/java/javax/jdo/spi/I18NHelper.java (original)
+++ db/jdo/trunk/api2/src/java/javax/jdo/spi/I18NHelper.java Fri Dec  5 14:20:54 2008
@@ -49,11 +49,13 @@
 
     /** Bundles that have already been loaded 
      */
-    private static Hashtable    bundles = new Hashtable();
+    private static Hashtable<String,ResourceBundle>
+            bundles = new Hashtable<String,ResourceBundle>();
     
     /** Helper instances that have already been created 
      */
-    private static Hashtable    helpers = new Hashtable();
+    private static Hashtable<String,I18NHelper>
+            helpers = new Hashtable<String,I18NHelper>();
     
     /** The default locale for this VM.
      */
@@ -111,9 +113,9 @@
      * @return the helper instance bound to the bundle
      */
     public static I18NHelper getInstance (final Class cls) {
-        ClassLoader classLoader = (ClassLoader) AccessController.doPrivileged (
-            new PrivilegedAction () {
-                public Object run () {
+        ClassLoader classLoader = AccessController.doPrivileged (
+            new PrivilegedAction<ClassLoader> () {
+                public ClassLoader run () {
                     return cls.getClassLoader();
                 }
             }
@@ -393,9 +395,9 @@
      * block because of security.
      */
     private static ClassLoader getSystemClassLoaderPrivileged() {
-        return (ClassLoader) AccessController.doPrivileged (
-            new PrivilegedAction () {
-                public Object run () {
+        return AccessController.doPrivileged (
+            new PrivilegedAction<ClassLoader> () {
+                public ClassLoader run () {
                     return ClassLoader.getSystemClassLoader();
                 }
             }

Modified: db/jdo/trunk/api2/src/java/javax/jdo/spi/JDOImplHelper.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/api2/src/java/javax/jdo/spi/JDOImplHelper.java?rev=723901&r1=723900&r2=723901&view=diff
==============================================================================
--- db/jdo/trunk/api2/src/java/javax/jdo/spi/JDOImplHelper.java (original)
+++ db/jdo/trunk/api2/src/java/javax/jdo/spi/JDOImplHelper.java Fri Dec  5 14:20:54 2008
@@ -76,22 +76,26 @@
      * are added by the static method in each <code>PersistenceCapable</code>

      * class.  Entries are never removed.
      */    
-    private static Map registeredClasses = 
-            Collections.synchronizedMap(new HashMap ());
+    private static Map<Class,Meta> registeredClasses =
+            Collections.synchronizedMap(new HashMap<Class,Meta> ());
     
     /** This Set contains all classes that have registered for setStateManager
      * permissions via authorizeStateManagerClass.
+     * Only the key is used in order to maintain a weak set of classes.
      */
-    private static Map authorizedStateManagerClasses = new WeakHashMap();
+    private static final Map<Class,Class>
+            authorizedStateManagerClasses = new WeakHashMap<Class,Class>();
 
     /** This list contains the registered listeners for 
      * <code>RegisterClassEvent</code>s.
      */
-    private static List listeners = new ArrayList();
+    private static final List<RegisterClassListener>
+            listeners = new ArrayList<RegisterClassListener>();
     
     /** The list of registered StateInterrogation instances
      */
-    private static List stateInterrogations = new ArrayList();
+    private static List<StateInterrogation>
+            stateInterrogations = new ArrayList<StateInterrogation>();
 
     /** The singleton <code>JDOImplHelper</code> instance.
      */    
@@ -445,7 +449,7 @@
             // registrations might occur, and will then all wait until this 
             // synchronized block completes. Some of the class registrations 
             // might be delivered twice to the newly registered listener.
-            alreadyRegisteredClasses = new HashSet (registeredClasses.keySet());
+            alreadyRegisteredClasses = new HashSet<Class> (registeredClasses.keySet());
         }
         // new registrations will call the new listener while the following 
         // occurs notify the new listener about already-registered classes
@@ -475,7 +479,7 @@
      * persistence-capable classes.
      * @return registered persistence-capable classes
      */
-    public Collection getRegisteredClasses() {
+    public Collection<Class> getRegisteredClasses() {
         return Collections.unmodifiableCollection(registeredClasses.keySet());
     }
 
@@ -649,7 +653,8 @@
      * keyed on class instance and the value is an instance of 
      * StringConstructor.
      */
-    static Map stringConstructorMap = new HashMap();
+    static final Map<Class,StringConstructor> stringConstructorMap =
+            new HashMap<Class,StringConstructor>();
 
     /**
      * 
@@ -810,9 +815,9 @@
     static DateFormat getDateTimeInstance() {
         DateFormat result = null;
         try {
-        result = (DateFormat) AccessController.doPrivileged (
-            new PrivilegedAction () {
-                public Object run () {
+        result = AccessController.doPrivileged (
+            new PrivilegedAction<DateFormat> () {
+                public DateFormat run () {
                     return DateFormat.getDateTimeInstance();
                 }
             }
@@ -943,7 +948,8 @@
      * @param si the StateInterrogation to add
      */
     public synchronized void addStateInterrogation(StateInterrogation si) {
-        List newList = new ArrayList(stateInterrogations);
+        List<StateInterrogation> newList =
+                new ArrayList<StateInterrogation>(stateInterrogations);
         newList.add(si);
         stateInterrogations = newList;
     }
@@ -954,7 +960,8 @@
      * @param si the StateInterrogation to remove
      */
     public synchronized void removeStateInterrogation(StateInterrogation si) {
-        List newList = new ArrayList(stateInterrogations);
+        List<StateInterrogation> newList =
+                new ArrayList<StateInterrogation>(stateInterrogations);
         newList.remove(si);
         stateInterrogations = newList;
     }



Mime
View raw message