Author: hlship
Date: Sat Apr 22 18:08:18 2006
New Revision: 396187

URL: http://svn.apache.org/viewcvs?rev=396187&view=rev
Log:
Add an aspect that checks method parameters for nulls (unless supressed using 
an annotation).

Added:
    
tapestry/tapestry5/tapestry-core/trunk/src/main/aspect/org/apache/tapestry/internal/aspects/AbstractCatchNullParametersAspect.aj
    
tapestry/tapestry5/tapestry-core/trunk/src/main/aspect/org/apache/tapestry/internal/aspects/InternalCatchNullParametersAspect.aj
    
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/annotations/SuppressNullCheck.java
    
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/CatchNullParametersAspectTest.java
    
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/NullTarget.java
    
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/PartiallySuppressedNullTarget.java
    
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/SuppressedNullTarget.java
Modified:
    
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/annotations/Utility.java
    
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/transform/InternalClassTransformationImpl.java
    
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/BaseTestCase.java
    
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/transform/MethodSignature.java
    
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/util/Defense.java
    
tapestry/tapestry5/tapestry-core/trunk/src/main/resources/META-INF/hivemodule.xml
    
tapestry/tapestry5/tapestry-core/trunk/src/main/resources/META-INF/org.apache.tapestry.internal.transform.xml
    
tapestry/tapestry5/tapestry-core/trunk/src/main/resources/META-INF/org.apache.tapestry.transform.xml
    
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/InternalUtilityAspectTest.java
    
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/transform/InternalClassTransformationImplTest.java

Added: 
tapestry/tapestry5/tapestry-core/trunk/src/main/aspect/org/apache/tapestry/internal/aspects/AbstractCatchNullParametersAspect.aj
URL: 
http://svn.apache.org/viewcvs/tapestry/tapestry5/tapestry-core/trunk/src/main/aspect/org/apache/tapestry/internal/aspects/AbstractCatchNullParametersAspect.aj?rev=396187&view=auto
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/main/aspect/org/apache/tapestry/internal/aspects/AbstractCatchNullParametersAspect.aj
 (added)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/main/aspect/org/apache/tapestry/internal/aspects/AbstractCatchNullParametersAspect.aj
 Sat Apr 22 18:08:18 2006
@@ -0,0 +1,73 @@
+package org.apache.tapestry.internal.aspects;
+
+import org.apache.tapestry.internal.annotations.SuppressNullCheck;
+
+/**
+ * Adds code to targeted methods and constructors that prevents null values 
from being passed in as
+ * parameters.
+ */
[EMAIL PROTECTED]
+public abstract aspect AbstractCatchNullParametersAspect
+{
+    /**
+     * Overridden in concrete aspects to identify which classes are affected 
(typically, all within
+     * a particular package).
+     */
+    abstract pointcut targetClasses();
+
+    pointcut typeNotMarkedAsSuppressed() : 
+        !within(@SuppressNullCheck Object+);
+
+    /** Look for methods and constructors that do NOT have the 
SuppressNullCheck annotation. */
+    pointcut codeNotMarkedAsSuppressed() :  
+        execution([EMAIL PROTECTED] !private * *(..)) ||
+        execution([EMAIL PROTECTED] !private new(..));
+
+    /**
+     * Exclude methods (and constructors) with no parameters. Also, exclude 
equals() since it has to
+     * accept null (and we don't want to force you to put the SupportNullCheck 
annotation on every
+     * class that overrides equals().
+     */
+    pointcut excludedMethods() :
+        execution(* *()) ||
+        execution(new ()) ||
+        execution(boolean equals(Object));
+
+    /**
+     * Because this aspect can apply so widely, we explicitly exclude the 
aspect from advising
+     * itself.
+     */
+    pointcut methodsToCheck()  :
+        targetClasses() &&
+        typeNotMarkedAsSuppressed() &&
+        codeNotMarkedAsSuppressed() &&
+        !excludedMethods();
+
+    /**
+     * Here's where the real work gets done. I think there may be a way to do 
this more efficiently
+     * where much more static logic is injected, triggered by arguments.
+     */
+    before() : methodsToCheck() {
+        Object[] args = thisJoinPoint.getArgs();
+
+        for (int i = 0; i < args.length; i++)
+        {
+            if (args[i] == null)
+            {
+                // Because this aspect advises the execution of the method 
(rather than the call
+                // into the method),
+                // we can't say who called the method ... but that will show 
up in the stack trace.
+
+                String message = String.format(
+                        "Parameter #%d passed to method %s (at %s) was null.",
+                        i + 1,
+                        thisJoinPoint.getSignature().toString(),
+                        thisJoinPoint.getSourceLocation());
+
+                System.err.println(message);
+
+                throw new IllegalArgumentException(message);
+            }
+        }
+    }
+}

Added: 
tapestry/tapestry5/tapestry-core/trunk/src/main/aspect/org/apache/tapestry/internal/aspects/InternalCatchNullParametersAspect.aj
URL: 
http://svn.apache.org/viewcvs/tapestry/tapestry5/tapestry-core/trunk/src/main/aspect/org/apache/tapestry/internal/aspects/InternalCatchNullParametersAspect.aj?rev=396187&view=auto
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/main/aspect/org/apache/tapestry/internal/aspects/InternalCatchNullParametersAspect.aj
 (added)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/main/aspect/org/apache/tapestry/internal/aspects/InternalCatchNullParametersAspect.aj
 Sat Apr 22 18:08:18 2006
@@ -0,0 +1,15 @@
+package org.apache.tapestry.internal.aspects;
+
+import org.apache.tapestry.internal.annotations.SuppressNullCheck;
+
+/**
+ * Targets null checks to all the org.apache.tapestry classes.
+ * 
+ * @author Howard M. Lewis Ship
+ */
[EMAIL PROTECTED]
+public aspect InternalCatchNullParametersAspect extends 
AbstractCatchNullParametersAspect
+{
+    pointcut targetClasses()  :
+        within(org.apache.tapestry..*);
+}

Added: 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/annotations/SuppressNullCheck.java
URL: 
http://svn.apache.org/viewcvs/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/annotations/SuppressNullCheck.java?rev=396187&view=auto
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/annotations/SuppressNullCheck.java
 (added)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/annotations/SuppressNullCheck.java
 Sat Apr 22 18:08:18 2006
@@ -0,0 +1,37 @@
+// Copyright 2006 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.internal.annotations;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.CONSTRUCTOR;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * Marker annotation that is used to suppress the CatchNullParameters 
annotation. It can be applied
+ * to a type (but is <em>not</em> inherited), or it an be applied to 
individual methods or
+ * constructors.
+ * 
+ * @author Howard M. Lewis Ship
+ */
[EMAIL PROTECTED](
+{ TYPE, CONSTRUCTOR, METHOD })
[EMAIL PROTECTED](RUNTIME)
+public @interface SuppressNullCheck {
+
+}

Modified: 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/annotations/Utility.java
URL: 
http://svn.apache.org/viewcvs/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/annotations/Utility.java?rev=396187&r1=396186&r2=396187&view=diff
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/annotations/Utility.java
 (original)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/annotations/Utility.java
 Sat Apr 22 18:08:18 2006
@@ -1,3 +1,17 @@
+// Copyright 2006 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
 package org.apache.tapestry.internal.annotations;
 
 import java.lang.annotation.Documented;

Modified: 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/transform/InternalClassTransformationImpl.java
URL: 
http://svn.apache.org/viewcvs/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/transform/InternalClassTransformationImpl.java?rev=396187&r1=396186&r2=396187&view=diff
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/transform/InternalClassTransformationImpl.java
 (original)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/transform/InternalClassTransformationImpl.java
 Sat Apr 22 18:08:18 2006
@@ -35,6 +35,7 @@
 import javassist.expr.FieldAccess;
 
 import org.apache.hivemind.service.BodyBuilder;
+import org.apache.tapestry.internal.annotations.SuppressNullCheck;
 import org.apache.tapestry.transform.MethodSignature;
 import org.apache.tapestry.util.IdAllocator;
 
@@ -90,6 +91,7 @@
 
         private final Object _value;
 
+        @SuppressNullCheck
         ConstructorArg(Class type, String fieldName, Object value)
         {
             _type = type;
@@ -115,7 +117,7 @@
 
     public InternalClassTransformationImpl(CtClass ctClass)
     {
-        _ctClass = notNull(ctClass, "ctClass");
+        _ctClass = ctClass;
         _classPool = _ctClass.getClassPool();
 
         preloadMemberNames();
@@ -171,8 +173,6 @@
 
     public <T extends Annotation> T getAnnotation(Class<T> annotationClass)
     {
-        notNull(annotationClass, "annotationClass");
-
         Object[] annotations = findClassAnnotations();
 
         return findAnnotationInList(annotationClass, annotations);
@@ -607,6 +607,7 @@
         return fieldName;
     }
 
+    @SuppressNullCheck
     public String addInjectedField(Class type, String suggestedName, Object 
value)
     {
         notNull(type, "type");

Modified: 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/BaseTestCase.java
URL: 
http://svn.apache.org/viewcvs/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/BaseTestCase.java?rev=396187&r1=396186&r2=396187&view=diff
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/BaseTestCase.java
 (original)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/test/BaseTestCase.java
 Sat Apr 22 18:08:18 2006
@@ -19,9 +19,9 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.tapestry.internal.InternalComponentResources;
+import org.apache.tapestry.internal.annotations.SuppressNullCheck;
 import org.apache.tapestry.model.MutableComponentModel;
 import org.apache.tapestry.transform.ClassTransformation;
-import org.apache.tapestry.util.CollectionFactory;
 
 import static org.apache.tapestry.util.CollectionFactory.newList;
 
@@ -31,6 +31,7 @@
  * 
  * @author Howard M. Lewis Ship
  */
[EMAIL PROTECTED]
 public abstract class BaseTestCase extends TestBase
 {
     protected final void trainFindFieldsWithAnnotation(ClassTransformation 
transformation,
@@ -74,13 +75,15 @@
         return newMock(InternalComponentResources.class);
     }
 
-    protected final void trainAddInjectedField(ClassTransformation ct, Class 
type, String suggestedName, Object value, String fieldName)
+    protected final void trainAddInjectedField(ClassTransformation ct, Class 
type,
+            String suggestedName, Object value, String fieldName)
     {
         ct.addInjectedField(type, suggestedName, value);
         setReturnValue(fieldName);
     }
 
-    protected final void trainFindUnclaimedFields(ClassTransformation 
transformation, String... fieldNames)
+    protected final void trainFindUnclaimedFields(ClassTransformation 
transformation,
+            String... fieldNames)
     {
         transformation.findUnclaimedFields();
         setReturnValue(fieldNames);

Modified: 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/transform/MethodSignature.java
URL: 
http://svn.apache.org/viewcvs/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/transform/MethodSignature.java?rev=396187&r1=396186&r2=396187&view=diff
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/transform/MethodSignature.java
 (original)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/transform/MethodSignature.java
 Sat Apr 22 18:08:18 2006
@@ -16,6 +16,8 @@
 
 import java.lang.reflect.Modifier;
 
+import org.apache.tapestry.internal.annotations.SuppressNullCheck;
+
 import static org.apache.tapestry.util.Defense.notBlank;
 
 /**
@@ -46,11 +48,13 @@
 
     /** Convienience for adding a public void method with no parameters or 
exception types. */
 
+    @SuppressNullCheck
     public MethodSignature(String name)
     {
         this(Modifier.PUBLIC, "void", name, EMPTY_STRINGS, EMPTY_STRINGS);
     }
 
+    @SuppressNullCheck
     public MethodSignature(int modifiers, String type, String name, String[] 
parameterTypes,
             String[] exceptionTypes)
     {

Modified: 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/util/Defense.java
URL: 
http://svn.apache.org/viewcvs/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/util/Defense.java?rev=396187&r1=396186&r2=396187&view=diff
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/util/Defense.java
 (original)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/util/Defense.java
 Sat Apr 22 18:08:18 2006
@@ -14,6 +14,7 @@
 
 package org.apache.tapestry.util;
 
+import org.apache.tapestry.internal.annotations.SuppressNullCheck;
 import org.apache.tapestry.internal.annotations.Utility;
 
 /**
@@ -21,7 +22,7 @@
  * 
  * @author Howard M. Lewis Ship
  */
[EMAIL PROTECTED]
[EMAIL PROTECTED] @SuppressNullCheck
 public final class Defense
 {
 

Modified: 
tapestry/tapestry5/tapestry-core/trunk/src/main/resources/META-INF/hivemodule.xml
URL: 
http://svn.apache.org/viewcvs/tapestry/tapestry5/tapestry-core/trunk/src/main/resources/META-INF/hivemodule.xml?rev=396187&r1=396186&r2=396187&view=diff
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/main/resources/META-INF/hivemodule.xml
 (original)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/main/resources/META-INF/hivemodule.xml
 Sat Apr 22 18:08:18 2006
@@ -1,4 +1,20 @@
 <?xml version="1.0"?>
+<!-- 
+   Copyright 2006 The Apache Software Foundation
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+
 <module id="tapestry" version="5.0.0">
     
     Master module for Tapestry 5.

Modified: 
tapestry/tapestry5/tapestry-core/trunk/src/main/resources/META-INF/org.apache.tapestry.internal.transform.xml
URL: 
http://svn.apache.org/viewcvs/tapestry/tapestry5/tapestry-core/trunk/src/main/resources/META-INF/org.apache.tapestry.internal.transform.xml?rev=396187&r1=396186&r2=396187&view=diff
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/main/resources/META-INF/org.apache.tapestry.internal.transform.xml
 (original)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/main/resources/META-INF/org.apache.tapestry.internal.transform.xml
 Sat Apr 22 18:08:18 2006
@@ -1,4 +1,20 @@
 <?xml version="1.0"?>
+<!-- 
+   Copyright 2006 The Apache Software Foundation
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+
 <module id="org.apache.tapestry.internal.transform" version="5.0.0">
     
     <contribution 
configuration-id="org.apache.tapestry.transform.TransformWorkers">

Modified: 
tapestry/tapestry5/tapestry-core/trunk/src/main/resources/META-INF/org.apache.tapestry.transform.xml
URL: 
http://svn.apache.org/viewcvs/tapestry/tapestry5/tapestry-core/trunk/src/main/resources/META-INF/org.apache.tapestry.transform.xml?rev=396187&r1=396186&r2=396187&view=diff
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/main/resources/META-INF/org.apache.tapestry.transform.xml
 (original)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/main/resources/META-INF/org.apache.tapestry.transform.xml
 Sat Apr 22 18:08:18 2006
@@ -1,4 +1,20 @@
 <module id="org.apache.tapestry.transform" version="5.0.0">    
+<!-- 
+   Copyright 2006 The Apache Software Foundation
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+
     <configuration-point id="TransformWorkers" 
schema-id="hivemind.lib.ChainContribution">
         
         Defines a command chain of workers objects (implementing the 

Added: 
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/CatchNullParametersAspectTest.java
URL: 
http://svn.apache.org/viewcvs/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/CatchNullParametersAspectTest.java?rev=396187&view=auto
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/CatchNullParametersAspectTest.java
 (added)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/CatchNullParametersAspectTest.java
 Sat Apr 22 18:08:18 2006
@@ -0,0 +1,106 @@
+// Copyright 2006 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.internal.aspects;
+
+import org.apache.tapestry.test.TestBase;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertNotNull;
+
+/**
+ * Tricky one to test. Just need to invoke methods and ensure that null checks 
do and do not occur.
+ * 
+ * @author Howard M. Lewis Ship
+ */
+public class CatchNullParametersAspectTest extends TestBase
+{
+    @Test
+    public void publicConstructor()
+    {
+        new NullTarget("not null");
+
+        try
+        {
+            new NullTarget(null);
+            unreachable();
+        }
+        catch (IllegalArgumentException ex)
+        {
+            // Expected.
+        }
+    }
+
+    @Test
+    public void privateConstructor()
+    {
+        // This should work
+
+        assertNotNull(NullTarget.createUsingPrivateConstructor());
+    }
+
+    @Test
+    public void publicMethod()
+    {
+        NullTarget t = new NullTarget();
+
+        t.someMethod("not null");
+
+        try
+        {
+            t.someMethod(null);
+            unreachable();
+        }
+        catch (IllegalArgumentException ex)
+        {
+            // Expected.
+        }
+    }
+
+    @Test
+    public void privateMethod()
+    {
+        NullTarget t = new NullTarget();
+
+        t.sendNullToPrivate();
+    }
+
+    @Test
+    public void suppressedConstructor()
+    {
+        // Succeeds:
+        new SuppressedNullTarget(null);
+    }
+
+    @Test
+    public void suppressedPublicMethod()
+    {
+        // Succeeds:
+        new SuppressedNullTarget(null).publicMethod(null);
+    }
+
+    @Test
+    public void directlySuppressedConstructor()
+    {
+        // Succeeds:
+        new PartiallySuppressedNullTarget(null);
+    }
+
+    @Test
+    public void directlySuppressedPublicMethod()
+    {
+        // Succeeds:
+        new PartiallySuppressedNullTarget(null).publicMethod(null);
+    }
+}

Modified: 
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/InternalUtilityAspectTest.java
URL: 
http://svn.apache.org/viewcvs/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/InternalUtilityAspectTest.java?rev=396187&r1=396186&r2=396187&view=diff
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/InternalUtilityAspectTest.java
 (original)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/InternalUtilityAspectTest.java
 Sat Apr 22 18:08:18 2006
@@ -1,3 +1,17 @@
+// Copyright 2006 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
 package org.apache.tapestry.internal.aspects;
 
 import org.apache.tapestry.test.TestBase;

Added: 
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/NullTarget.java
URL: 
http://svn.apache.org/viewcvs/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/NullTarget.java?rev=396187&view=auto
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/NullTarget.java
 (added)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/NullTarget.java
 Sat Apr 22 18:08:18 2006
@@ -0,0 +1,56 @@
+// Copyright 2006 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.internal.aspects;
+
+public class NullTarget
+{
+    public NullTarget()
+    {
+
+    }
+
+    // Null check enforced
+    public NullTarget(String parameter)
+    {
+
+    }
+
+    // Private method, null check not enforced
+
+    private NullTarget(String param1, String param2)
+    {
+
+    }
+
+    public static NullTarget createUsingPrivateConstructor()
+    {
+        return new NullTarget(null, null);
+    }
+
+    public void someMethod(String parameter)
+    {
+        
+    }
+    
+    public void sendNullToPrivate()
+    {
+        privateMethod(null);
+    }
+    
+    private void privateMethod(String parameter)
+    {
+        
+    }
+}

Added: 
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/PartiallySuppressedNullTarget.java
URL: 
http://svn.apache.org/viewcvs/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/PartiallySuppressedNullTarget.java?rev=396187&view=auto
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/PartiallySuppressedNullTarget.java
 (added)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/PartiallySuppressedNullTarget.java
 Sat Apr 22 18:08:18 2006
@@ -0,0 +1,32 @@
+// Copyright 2006 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.internal.aspects;
+
+import org.apache.tapestry.internal.annotations.SuppressNullCheck;
+
+public class PartiallySuppressedNullTarget
+{
+    @SuppressNullCheck
+    public PartiallySuppressedNullTarget(String parameter)
+    {
+
+    }
+
+    @SuppressNullCheck
+    public void publicMethod(String parameter)
+    {
+
+    }
+}

Added: 
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/SuppressedNullTarget.java
URL: 
http://svn.apache.org/viewcvs/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/SuppressedNullTarget.java?rev=396187&view=auto
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/SuppressedNullTarget.java
 (added)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/aspects/SuppressedNullTarget.java
 Sat Apr 22 18:08:18 2006
@@ -0,0 +1,31 @@
+// Copyright 2006 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.internal.aspects;
+
+import org.apache.tapestry.internal.annotations.SuppressNullCheck;
+
[EMAIL PROTECTED]
+public class SuppressedNullTarget
+{
+    public SuppressedNullTarget(String parameter)
+    {
+
+    }
+
+    public void publicMethod(String parameter)
+    {
+
+    }
+}

Modified: 
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/transform/InternalClassTransformationImplTest.java
URL: 
http://svn.apache.org/viewcvs/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/transform/InternalClassTransformationImplTest.java?rev=396187&r1=396186&r2=396187&view=diff
==============================================================================
--- 
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/transform/InternalClassTransformationImplTest.java
 (original)
+++ 
tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/transform/InternalClassTransformationImplTest.java
 Sat Apr 22 18:08:18 2006
@@ -415,6 +415,7 @@
     public void addImplementedInterface() throws Exception
     {
         MutableComponentModel model = newMutableComponentModel();
+        InternalComponentResources resources = newInternalComponentResources();
 
         replay();
 
@@ -444,7 +445,7 @@
         assertEquals(interfaces, new Class[]
         { ResourceAware.class, FooInterface.class, 
GetterMethodsInterface.class });
 
-        Object target = ct.createInstantiator(transformed).newInstance(null);
+        Object target = 
ct.createInstantiator(transformed).newInstance(resources);
 
         FooInterface asFoo = (FooInterface) target;
 



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to