[jboss-cvs] JBossAS SVN: r94875 - in projects/jboss-cl/trunk: classloader/src/main/java/org/jboss/classloader/spi/filter and 7 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Oct 14 12:01:46 EDT 2009
Author: adrian at jboss.org
Date: 2009-10-14 12:01:45 -0400 (Wed, 14 Oct 2009)
New Revision: 94875
Modified:
projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoaderDomain.java
projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoaderPolicy.java
projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoaderSystem.java
projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/ClassLoadingTask.java
projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/filter/FilteredDelegateLoader.java
projects/jboss-cl/trunk/classloading-vfs/src/main/java/org/jboss/classloading/spi/vfs/metadata/VFSClassLoaderFactory.java
projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/plugins/metadata/PackageCapability.java
projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/dependency/ClassLoading.java
projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/dependency/policy/mock/MockClassLoadingMetaData.java
projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/metadata/ClassLoadingMetaData.java
projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/metadata/helpers/AbstractRequirement.java
projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/version/Version.java
projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/version/VersionComparatorRegistry.java
Log:
[JBCL-123] - Obvious FindBug corrections, some redundant code to lower the noise and comments where no change is required.
Modified: projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoaderDomain.java
===================================================================
--- projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoaderDomain.java 2009-10-14 15:23:40 UTC (rev 94874)
+++ projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoaderDomain.java 2009-10-14 16:01:45 UTC (rev 94875)
@@ -1295,6 +1295,7 @@
BaseClassLoaderPolicy basePolicy = classLoader.getPolicy();
basePolicy.setClassLoaderDomain(this);
+ // FINDBUGS: This synchronization is correct - more than addIfNotPresent behaviour
synchronized (classLoaders)
{
// Create the information
@@ -1353,6 +1354,7 @@
BaseClassLoaderPolicy policy = classLoader.getPolicy();
policy.unsetClassLoaderDomain(this);
+ // FINDBUGS: This synchronization is correct - more than addIfNotPresent behaviour
synchronized (classLoaders)
{
// Remove the classloader
@@ -1537,7 +1539,7 @@
/**
* ClassCacheItem.
*/
- class ClassCacheItem
+ static class ClassCacheItem
{
Loader loader;
Class<?> clazz;
@@ -1557,7 +1559,7 @@
{
if (loader != null)
return loader.toString();
- return null;
+ return "";
}
}
}
Modified: projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoaderPolicy.java
===================================================================
--- projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoaderPolicy.java 2009-10-14 15:23:40 UTC (rev 94874)
+++ projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoaderPolicy.java 2009-10-14 16:01:45 UTC (rev 94875)
@@ -162,7 +162,7 @@
ClassLoader classLoader = getClassLoaderUnchecked();
if (classLoader != null)
- result = TranslatorUtils.applyTranslatorsOnTransform(translators, classLoader, className, result, protectionDomain);
+ result = TranslatorUtils.applyTranslatorsOnTransform(getTranslators(), classLoader, className, result, protectionDomain);
return result;
}
@@ -336,7 +336,7 @@
log.debug(toString() + " shutdown!");
BaseClassLoader classLoader = this.classLoader;
this.classLoader = null;
- TranslatorUtils.applyTranslatorsAtUnregister(translators, classLoader);
+ TranslatorUtils.applyTranslatorsAtUnregister(getTranslators(), classLoader);
classLoader.shutdownClassLoader();
}
@@ -358,7 +358,7 @@
*
* @return the translators
*/
- public List<Translator> getTranslators()
+ public synchronized List<Translator> getTranslators()
{
if (translators == null || translators.isEmpty())
return Collections.emptyList();
Modified: projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoaderSystem.java
===================================================================
--- projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoaderSystem.java 2009-10-14 15:23:40 UTC (rev 94874)
+++ projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/BaseClassLoaderSystem.java 2009-10-14 16:01:45 UTC (rev 94875)
@@ -176,6 +176,7 @@
*/
protected BaseClassLoader createClassLoader(ClassLoaderPolicy policy)
{
+ // FINDBUGS: This is correct we want to use the caller's access control context
return new BaseClassLoader(policy);
}
Modified: projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/ClassLoadingTask.java
===================================================================
--- projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/ClassLoadingTask.java 2009-10-14 15:23:40 UTC (rev 94874)
+++ projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/base/ClassLoadingTask.java 2009-10-14 16:01:45 UTC (rev 94875)
@@ -27,6 +27,7 @@
import java.security.CodeSource;
import java.security.PrivilegedAction;
import java.security.ProtectionDomain;
+import java.util.concurrent.atomic.AtomicReference;
import org.jboss.classloader.plugins.ClassLoaderUtils;
import org.jboss.classloader.spi.Loader;
@@ -72,7 +73,7 @@
private ClassLoader classLoader;
/** The loaded class */
- private Class<?> loadedClass;
+ private AtomicReference<Class<?>> loadedClass = new AtomicReference<Class<?>>();
/** The error during the load */
private Throwable loadException;
@@ -118,9 +119,9 @@
*
* @return the loadedClass.
*/
- synchronized Class<?> getLoadedClass()
+ Class<?> getLoadedClass()
{
- return loadedClass;
+ return loadedClass.get();
}
/**
@@ -170,7 +171,7 @@
*/
synchronized void finish(Class<?> loadedClass)
{
- this.loadedClass = loadedClass;
+ this.loadedClass.set(loadedClass);
state = TaskState.FINISHED;
}
@@ -226,6 +227,7 @@
builder.append("className=").append(className);
builder.append(" requestingThread=").append(requestingThread);
builder.append(" requestingClassLoader: ").append(classLoader);
+ Class<?> loadedClass = getLoadedClass();
if (loadedClass != null)
{
builder.append(" loadedClass=");
@@ -294,7 +296,8 @@
log.trace("setLoadedClass, theClass=" + theClass);
// Warn about duplicate classes
- if (this.loadedClass != null && theClass != null)
+ Class<?> loadedClass = getLoadedClass();
+ if (loadedClass != null && theClass != null)
{
StringBuilder builder = new StringBuilder();
builder.append("Duplicate class found: ").append(className).append('\n');
@@ -309,7 +312,7 @@
// Accept the first class
if (theClass != null && loadedClass == null)
- this.loadedClass = theClass;
+ this.loadedClass.set(theClass);
}
/**
@@ -357,7 +360,7 @@
*/
Class<?> getLoadedClass()
{
- return loadedClass;
+ return loadedClass.get();
}
@Override
@@ -447,6 +450,7 @@
*/
void run() throws ClassNotFoundException
{
+ Class<?> loadedClass = getLoadedClass();
if (loadedClass == null)
{
Class<?> theClass = loader.loadClass(className);
Modified: projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/filter/FilteredDelegateLoader.java
===================================================================
--- projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/filter/FilteredDelegateLoader.java 2009-10-14 15:23:40 UTC (rev 94874)
+++ projects/jboss-cl/trunk/classloader/src/main/java/org/jboss/classloader/spi/filter/FilteredDelegateLoader.java 2009-10-14 16:01:45 UTC (rev 94875)
@@ -115,7 +115,7 @@
protected void setFilter(ClassFilter filter)
{
if (filter == null)
- filter = ClassFilter.EVERYTHING;
+ this.filter = ClassFilter.EVERYTHING;
else
this.filter = filter;
}
Modified: projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/plugins/metadata/PackageCapability.java
===================================================================
--- projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/plugins/metadata/PackageCapability.java 2009-10-14 15:23:40 UTC (rev 94874)
+++ projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/plugins/metadata/PackageCapability.java 2009-10-14 16:01:45 UTC (rev 94875)
@@ -143,4 +143,11 @@
return false;
return super.equals(obj);
}
+
+ // FINDBUGS: Just to keep it happy
+ @Override
+ public int hashCode()
+ {
+ return super.hashCode();
+ }
}
Modified: projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/dependency/ClassLoading.java
===================================================================
--- projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/dependency/ClassLoading.java 2009-10-14 15:23:40 UTC (rev 94874)
+++ projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/dependency/ClassLoading.java 2009-10-14 16:01:45 UTC (rev 94875)
@@ -164,6 +164,7 @@
protected Domain getDomain(String domainName, String parentDomainName, boolean parentFirst)
{
Domain domain;
+ // FINDBUGS: This synchronization is correct - more than addIfNotPresent behaviour
synchronized (domains)
{
domain = getDomain(domainName);
Modified: projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/dependency/policy/mock/MockClassLoadingMetaData.java
===================================================================
--- projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/dependency/policy/mock/MockClassLoadingMetaData.java 2009-10-14 15:23:40 UTC (rev 94874)
+++ projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/dependency/policy/mock/MockClassLoadingMetaData.java 2009-10-14 16:01:45 UTC (rev 94875)
@@ -308,4 +308,18 @@
setExportedPackages(packages);
}
+
+ // FINDBUGS: Just to keep it happy
+ @Override
+ public boolean equals(Object obj)
+ {
+ return super.equals(obj);
+ }
+
+ // FINDBUGS: Just to keep it happy
+ @Override
+ public int hashCode()
+ {
+ return super.hashCode();
+ }
}
Modified: projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/metadata/ClassLoadingMetaData.java
===================================================================
--- projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/metadata/ClassLoadingMetaData.java 2009-10-14 15:23:40 UTC (rev 94874)
+++ projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/metadata/ClassLoadingMetaData.java 2009-10-14 16:01:45 UTC (rev 94875)
@@ -546,12 +546,17 @@
return true;
}
+ // FINDBUGS: Just to keep it happy
+ @Override
+ public int hashCode()
+ {
+ return super.hashCode();
+ }
+
private static boolean equals(Object one, Object two)
{
- if (one == null && two == null)
- return true;
- if (one == null && two != null)
- return false;
+ if (one == null)
+ return two == null;
return one.equals(two);
}
Modified: projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/metadata/helpers/AbstractRequirement.java
===================================================================
--- projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/metadata/helpers/AbstractRequirement.java 2009-10-14 15:23:40 UTC (rev 94874)
+++ projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/metadata/helpers/AbstractRequirement.java 2009-10-14 16:01:45 UTC (rev 94875)
@@ -182,6 +182,13 @@
return false;
return true;
}
+
+ // FINDBUGS: Just to keep it happy
+ @Override
+ public int hashCode()
+ {
+ return super.hashCode();
+ }
@Override
public String toString()
Modified: projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/version/Version.java
===================================================================
--- projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/version/Version.java 2009-10-14 15:23:40 UTC (rev 94874)
+++ projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/version/Version.java 2009-10-14 16:01:45 UTC (rev 94875)
@@ -255,6 +255,7 @@
}
@Override
+ // FINDBUGS: Not suprising it doesn't understand this :-)
public boolean equals(Object object)
{
if (object == this)
Modified: projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/version/VersionComparatorRegistry.java
===================================================================
--- projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/version/VersionComparatorRegistry.java 2009-10-14 15:23:40 UTC (rev 94874)
+++ projects/jboss-cl/trunk/classloading/src/main/java/org/jboss/classloading/spi/version/VersionComparatorRegistry.java 2009-10-14 16:01:45 UTC (rev 94875)
@@ -266,7 +266,7 @@
* @param <T> the first version type
* @param <U> the second version type
*/
- private class SwitchVersionComparator<T, U> implements VersionComparator<T, U>
+ private static class SwitchVersionComparator<T, U> implements VersionComparator<T, U>
{
/** The delegate */
private VersionComparator<U, T> delegate;
@@ -292,7 +292,7 @@
/**
* VersionToVersionComparator.
*/
- private class VersionToVersionComparator implements VersionComparator<Version, Version>
+ private static class VersionToVersionComparator implements VersionComparator<Version, Version>
{
public int compare(Version t, Version u)
{
@@ -303,7 +303,7 @@
/**
* VersionToStringComparator.
*/
- private class VersionToStringComparator implements VersionComparator<Version, String>
+ private static class VersionToStringComparator implements VersionComparator<Version, String>
{
public int compare(Version t, String u)
{
@@ -314,7 +314,7 @@
/**
* StringToStringComparator.
*/
- private class StringToStringComparator implements VersionComparator<String, String>
+ private static class StringToStringComparator implements VersionComparator<String, String>
{
public int compare(String t, String u)
{
Modified: projects/jboss-cl/trunk/classloading-vfs/src/main/java/org/jboss/classloading/spi/vfs/metadata/VFSClassLoaderFactory.java
===================================================================
--- projects/jboss-cl/trunk/classloading-vfs/src/main/java/org/jboss/classloading/spi/vfs/metadata/VFSClassLoaderFactory.java 2009-10-14 15:23:40 UTC (rev 94874)
+++ projects/jboss-cl/trunk/classloading-vfs/src/main/java/org/jboss/classloading/spi/vfs/metadata/VFSClassLoaderFactory.java 2009-10-14 16:01:45 UTC (rev 94875)
@@ -209,4 +209,18 @@
return Arrays.asList(classLoader, module);
}
+
+ // FINDBUGS: Just to keep it happy
+ @Override
+ public boolean equals(Object obj)
+ {
+ return super.equals(obj);
+ }
+
+ // FINDBUGS: Just to keep it happy
+ @Override
+ public int hashCode()
+ {
+ return super.hashCode();
+ }
}
More information about the jboss-cvs-commits
mailing list