Author: nbubna
Date: Thu Feb 19 05:34:13 2009
New Revision: 745736

URL: http://svn.apache.org/viewvc?rev=745736&view=rev
Log:
VELOCITY-701 remove unnecessary exclusion of public abstract methods in public 
classes

Added:
    
velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity701TestCase.java
   (with props)
Modified:
    
velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/ClassMap.java

Modified: 
velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/ClassMap.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/ClassMap.java?rev=745736&r1=745735&r2=745736&view=diff
==============================================================================
--- 
velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/ClassMap.java
 (original)
+++ 
velocity/engine/trunk/src/java/org/apache/velocity/util/introspection/ClassMap.java
 Thu Feb 19 05:34:13 2009
@@ -164,22 +164,12 @@
         try
         {
             Method[] methods = classToReflect.getDeclaredMethods();
-
             for (int i = 0; i < methods.length; i++)
             {
-                // Strictly spoken that check shouldn't be necessary
-                // because getMethods only returns public methods.
                 int modifiers = methods[i].getModifiers();
-                if (Modifier.isPublic(modifiers)) //  && !)
+                if (Modifier.isPublic(modifiers))
                 {
-                    // Some of the interfaces contain abstract methods. That 
is fine, because the actual object must 
-                    // implement them anyway (else it wouldn't be implementing 
the interface). If we find an abstract
-                    // method in a non-interface, we skip it, because we do 
want to make sure that no abstract methods end up in
-                    // the cache.                       
-                    if (classToReflect.isInterface() || 
!Modifier.isAbstract(modifiers))
-                    {
-                        methodCache.put(methods[i]);
-                    }
+                    methodCache.put(methods[i]);
                 }
             }
         }

Added: 
velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity701TestCase.java
URL: 
http://svn.apache.org/viewvc/velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity701TestCase.java?rev=745736&view=auto
==============================================================================
--- 
velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity701TestCase.java
 (added)
+++ 
velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity701TestCase.java
 Thu Feb 19 05:34:13 2009
@@ -0,0 +1,74 @@
+package org.apache.velocity.test.issues;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.    
+ */
+
+import java.lang.reflect.Modifier;
+import org.apache.velocity.test.BaseTestCase;
+import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.test.misc.TestLogChute;
+
+/**
+ * This class tests VELOCITY-701.
+ */
+public class Velocity701TestCase extends BaseTestCase
+{
+    public Velocity701TestCase(String name)
+    {
+        super(name);
+        //DEBUG = true;
+    }
+
+    public void testAbstractClass()
+    {
+        context.put("foo", new Foo() {
+            public String getBar() {
+                return "bar";
+            }
+        });
+        assertEvalEquals("bar", "$foo.bar");
+    }
+
+    public static abstract class Foo {
+        
+        public abstract String getBar();
+    
+    }
+
+    /* TODO: uncomment for jdk 1.5+
+    public void testEnum()
+    {
+        context.put("bar", Bar.ONE);
+        assertEvalEquals("foo", "$bar.foo");
+    }
+
+    public static enum Bar {
+
+        ONE(){
+            public String getFoo() {
+                return "foo";
+            }
+        };
+
+       //This was an abstract method, but Velocity 1.6 quit working with it.
+       public abstract String getFoo();
+
+    }*/
+
+}

Propchange: 
velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity701TestCase.java
------------------------------------------------------------------------------
    svn:executable = *


Reply via email to