You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by ek...@apache.org on 2006/01/23 19:27:52 UTC

svn commit: r371613 - /beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/ControlClientAnnotationProcessor.java

Author: ekoneil
Date: Mon Jan 23 10:27:50 2006
New Revision: 371613

URL: http://svn.apache.org/viewcvs?rev=371613&view=rev
Log:
Fix an NPE that occurs when building a Control that uses @Version and @VersionRequired annotations without setting a major version number.

BB: self
Test: Controls DRT pass


Modified:
    beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/ControlClientAnnotationProcessor.java

Modified: beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/ControlClientAnnotationProcessor.java
URL: http://svn.apache.org/viewcvs/beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/ControlClientAnnotationProcessor.java?rev=371613&r1=371612&r2=371613&view=diff
==============================================================================
--- beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/ControlClientAnnotationProcessor.java (original)
+++ beehive/trunk/controls/src/runtime/org/apache/beehive/controls/runtime/generator/apt/ControlClientAnnotationProcessor.java Mon Jan 23 10:27:50 2006
@@ -56,12 +56,10 @@
 import org.apache.beehive.controls.api.bean.ControlInterface;
 import org.apache.beehive.controls.api.bean.ControlExtension;
 
-public class ControlClientAnnotationProcessor extends TwoPhaseAnnotationProcessor
-{
+public class ControlClientAnnotationProcessor
+    extends TwoPhaseAnnotationProcessor {
 
-    public ControlClientAnnotationProcessor(
-        Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env )
-    {
+    public ControlClientAnnotationProcessor(Set<AnnotationTypeDeclaration> atds, AnnotationProcessorEnvironment env ) {
         super( atds,env );
     }
 
@@ -586,7 +584,20 @@
         Version versionPresent = controlIntf.getAnnotation(Version.class);
 
         if (versionRequired != null) {
-            int majorRequired = versionRequired.major();
+            int majorRequired = -1;
+            try {
+                majorRequired = versionRequired.major();
+            }
+            catch(NullPointerException ignore) {
+                /*
+                the major version annotation is required and if unspecified, will
+                throw an NPE when it is quereid but not provided.  this error will
+                be caught during syntactic validation perfoemed by javac, so ignore
+                it if an NPE is caught here
+                 */
+                return;
+            }
+
             int minorRequired = versionRequired.minor();
 
             /* no version requirement, so return */
@@ -597,7 +608,18 @@
             int minorPresent = -1;
             if ( versionPresent != null )
             {
-                majorPresent = versionPresent.major();
+                try {
+                    majorPresent = versionPresent.major();
+                }
+                catch(NullPointerException ignore) {
+                    /*
+                    the major version annotation is required and if unspecified, will
+                    throw an NPE when it is quereid but not provided.  this error will
+                    be caught during syntactic validation perfoemed by javac, so ignore
+                    it if an NPE is caught here
+                     */
+                }
+
                 minorPresent = versionPresent.minor();
 
                 if ( majorRequired <= majorPresent &&