geronimo-xbean-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1596328 - in /geronimo/xbean/trunk/xbean-finder/src: main/java/org/apache/xbean/finder/ test/java/org/apache/xbean/finder/
Date Tue, 20 May 2014 17:23:07 GMT
Author: rmannibucau
Date: Tue May 20 17:23:06 2014
New Revision: 1596328

URL: http://svn.apache.org/r1596328
Log:
XBEAN-267 javadoc for 267 and fix for XBEAN-263 creating ClassInfo for an annotated Class
object throws NPE

Modified:
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotationFinder.java
    geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AsynchronousInheritanceAnnotationFinder.java
    geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/ClassFinderDepthTest.java

Modified: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotationFinder.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotationFinder.java?rev=1596328&r1=1596327&r2=1596328&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotationFinder.java
(original)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AnnotationFinder.java
Tue May 20 17:23:06 2014
@@ -1698,8 +1698,12 @@ public class AnnotationFinder implements
         }
 
         public AnnotationInfo(String name) {
-            name = Type.getType(name).getClassName();
-            this.name = name.intern();
+            final Type type = Type.getType(name);
+            name = type.getClassName();
+            if (name == null) {
+                name = type.getDescriptor(); // name was already a class name
+            }
+            this.name = name;
         }
 
         public String getName() {

Modified: geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AsynchronousInheritanceAnnotationFinder.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AsynchronousInheritanceAnnotationFinder.java?rev=1596328&r1=1596327&r2=1596328&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AsynchronousInheritanceAnnotationFinder.java
(original)
+++ geronimo/xbean/trunk/xbean-finder/src/main/java/org/apache/xbean/finder/AsynchronousInheritanceAnnotationFinder.java
Tue May 20 17:23:06 2014
@@ -29,6 +29,7 @@ import java.util.concurrent.Executors;
 import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.atomic.AtomicInteger;
 
+// designed to trigger asynchronism from a single thread
 public class AsynchronousInheritanceAnnotationFinder extends AnnotationFinder {
     private ExecutorService executor = null;
     private CountDownLatch subclassesLatch = null;
@@ -43,7 +44,7 @@ public class AsynchronousInheritanceAnno
         super(archive);
     }
 
-    @Override
+    @Override // should be called from main thread
     public AnnotationFinder enableFindImplementations() {
         if (implementationsLatch == null) {
             enableFindSubclasses();
@@ -65,7 +66,7 @@ public class AsynchronousInheritanceAnno
         return this;
     }
 
-    @Override
+    @Override  // should be called from main thread
     public AnnotationFinder enableFindSubclasses() {
         if (subclassesLatch == null) {
             subclassesLatch = new CountDownLatch(1);
@@ -80,7 +81,7 @@ public class AsynchronousInheritanceAnno
         return this;
     }
 
-    @Override
+    @Override  // should be called from main thread
     public <T> List<Class<? extends T>> findSubclasses(final Class<T>
clazz) {
         if (subclassesLatch == null) {
             enableFindSubclasses();
@@ -89,7 +90,7 @@ public class AsynchronousInheritanceAnno
         return super.findSubclasses(clazz);
     }
 
-    @Override
+    @Override  // should be called from main thread
     public <T> List<Class<? extends T>> findImplementations(final Class<T>
clazz) {
         if (implementationsLatch == null) {
             enableFindImplementations();

Modified: geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/ClassFinderDepthTest.java
URL: http://svn.apache.org/viewvc/geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/ClassFinderDepthTest.java?rev=1596328&r1=1596327&r2=1596328&view=diff
==============================================================================
--- geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/ClassFinderDepthTest.java
(original)
+++ geronimo/xbean/trunk/xbean-finder/src/test/java/org/apache/xbean/finder/ClassFinderDepthTest.java
Tue May 20 17:23:06 2014
@@ -20,13 +20,16 @@ import junit.framework.TestCase;
 import org.apache.xbean.finder.archive.ClassesArchive;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 /**
  * @version $Rev$ $Date$
  */
 public class ClassFinderDepthTest extends TestCase {
-
+    @Deprecated
+    public static abstract class TargetImpl implements java.lang.annotation.Target {
+    }
 
     public static interface Hue<T> {
     }
@@ -74,6 +77,20 @@ public class ClassFinderDepthTest extend
         }
     }
 
+    public void testFindAnnotatedInterfaceImplementationsAfterGet() {
+        for (int i = 0; i < 10; i++) {
+                final ClassesArchive archive = new ClassesArchive(TargetImpl.class);
+                for (final AnnotationFinder finder : new AnnotationFinder[] {
+                            new AnnotationFinder(archive),
+                            new AsynchronousInheritanceAnnotationFinder(archive)
+                                }) {
+                        assertEquals(Collections.singletonList(TargetImpl.class), finder.findAnnotatedClasses(Deprecated.class));
+                        finder.link();
+                        assertImplementations(finder, java.lang.annotation.Target.class,
TargetImpl.class);
+                    }
+            }
+    }
+
     public void testFindImplementations() throws Exception {
         for (int i = 0; i < 10; i++) { // try to avoid AsynchronousInheritanceAnnotationFinder
"luck" issues
             for (final AnnotationFinder finder : new AnnotationFinder[] {



Mime
View raw message