From jdo-commits-return-2572-apmail-db-jdo-commits-archive=www.apache.org@db.apache.org Fri Dec 05 22:21:16 2008 Return-Path: Delivered-To: apmail-db-jdo-commits-archive@www.apache.org Received: (qmail 42304 invoked from network); 5 Dec 2008 22:21:16 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Dec 2008 22:21:16 -0000 Received: (qmail 68879 invoked by uid 500); 5 Dec 2008 22:21:28 -0000 Mailing-List: contact jdo-commits-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jdo-dev@db.apache.org Delivered-To: mailing list jdo-commits@db.apache.org Received: (qmail 68869 invoked by uid 99); 5 Dec 2008 22:21:28 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Dec 2008 14:21:28 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Dec 2008 22:20:06 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 3720E23888A3; Fri, 5 Dec 2008 14:20:55 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: jdo-commits@db.apache.org From: clr@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20081205222055.3720E23888A3@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 xref = new HashMap(); xref.put( PMF_ATTRIBUTE_CLASS, @@ -171,8 +171,8 @@ */ private static JDOImplHelper implHelper = (JDOImplHelper) AccessController.doPrivileged( - new PrivilegedAction () { - public Object run () { + new PrivilegedAction () { + 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 getObjectIds(Collection pcs) { + ArrayList result = new ArrayList(); 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 exceptions = new ArrayList(); if (pmfClassLoader == null) throw new JDOFatalUserException (msg.msg ( "EXC_GetPMFNullLoader")); //NOI18N @@ -1057,7 +1057,7 @@ "EXC_GetPMFNullPropsLoader")); //NOI18N } - Map props = null; + Map 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 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 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 getNamedPMFProperties( String name, ClassLoader resourceLoader, String jdoconfigResourceName) { // key is PU name, value is Map of PU properties - Map/**/ propertiesByNameInAllConfigs - = new HashMap/**/(); + Map> propertiesByNameInAllConfigs + = new HashMap>(); try { URL firstFoundConfigURL = null; // get all JDO configurations - Enumeration resources = + Enumeration resources = getResources(resourceLoader, jdoconfigResourceName); if (resources.hasMoreElements()) { - ArrayList processedResources = new ArrayList(); + ArrayList processedResources = new ArrayList(); // 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/**/ propertiesByNameInCurrentConfig = + Map> 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) 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/**/ readNamedPMFProperties( + protected static Map> readNamedPMFProperties( URL url, String requestedPMFName, DocumentBuilderFactory factory) { @@ -1391,7 +1393,8 @@ ? "" : requestedPMFName.trim(); - Map propertiesByName = new HashMap(); + Map> + propertiesByName = new HashMap>(); 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 exceptions = new ArrayList(); 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 () { + 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() { + 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() { + 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() { public Object run() throws IllegalAccessException, InvocationTargetException { @@ -1967,14 +1970,14 @@ * @param resourceName * @return the resources */ - protected static Enumeration getResources( + protected static Enumeration 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>() { + public Enumeration 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() { + 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() { + 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 () { + 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 + bundles = new Hashtable(); /** Helper instances that have already been created */ - private static Hashtable helpers = new Hashtable(); + private static Hashtable + helpers = new Hashtable(); /** 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 () { + 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 () { + 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 PersistenceCapable * class. Entries are never removed. */ - private static Map registeredClasses = - Collections.synchronizedMap(new HashMap ()); + private static Map registeredClasses = + Collections.synchronizedMap(new HashMap ()); /** 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 + authorizedStateManagerClasses = new WeakHashMap(); /** This list contains the registered listeners for * RegisterClassEvents. */ - private static List listeners = new ArrayList(); + private static final List + listeners = new ArrayList(); /** The list of registered StateInterrogation instances */ - private static List stateInterrogations = new ArrayList(); + private static List + stateInterrogations = new ArrayList(); /** The singleton JDOImplHelper 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 (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 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 stringConstructorMap = + new HashMap(); /** * @@ -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 () { + 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 newList = + new ArrayList(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 newList = + new ArrayList(stateInterrogations); newList.remove(si); stateInterrogations = newList; }