freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddek...@apache.org
Subject incubator-freemarker git commit: Removed the overridable BeansWrapper.finetuneMethodAppearance method, which was deprecated by the finetuneMethodAppearance setting (BeansWrapper.setFinetuneMethodAppearance).
Date Mon, 20 Feb 2017 18:41:03 GMT
Repository: incubator-freemarker
Updated Branches:
  refs/heads/3 d7f2d65bf -> f839a5677


Removed the overridable BeansWrapper.finetuneMethodAppearance method, which was deprecated
by the finetuneMethodAppearance setting (BeansWrapper.setFinetuneMethodAppearance).


Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/f839a567
Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/f839a567
Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/f839a567

Branch: refs/heads/3
Commit: f839a5677da5724601b48928664c50502ebd79b9
Parents: d7f2d65
Author: ddekany <ddekany@apache.org>
Authored: Mon Feb 20 19:04:33 2017 +0100
Committer: ddekany <ddekany@apache.org>
Committed: Mon Feb 20 19:40:50 2017 +0100

----------------------------------------------------------------------
 .../core/model/impl/beans/BeansWrapper.java     | 60 --------------------
 src/manual/en_US/FM3-CHANGE-LOG.txt             |  5 +-
 .../beans/FineTuneMethodAppearanceTest.java     | 42 ++------------
 3 files changed, 8 insertions(+), 99 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/f839a567/src/main/java/org/apache/freemarker/core/model/impl/beans/BeansWrapper.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/model/impl/beans/BeansWrapper.java b/src/main/java/org/apache/freemarker/core/model/impl/beans/BeansWrapper.java
index 183712c..182e27f 100644
--- a/src/main/java/org/apache/freemarker/core/model/impl/beans/BeansWrapper.java
+++ b/src/main/java/org/apache/freemarker/core/model/impl/beans/BeansWrapper.java
@@ -63,7 +63,6 @@ import org.apache.freemarker.core.model.TemplateScalarModel;
 import org.apache.freemarker.core.model.TemplateSequenceModel;
 import org.apache.freemarker.core.model.WrapperTemplateModel;
 import org.apache.freemarker.core.model.impl.DefaultObjectWrapper;
-import org.apache.freemarker.core.model.impl.SimpleObjectWrapper;
 import org.apache.freemarker.core.util.UndeclaredThrowableException;
 import org.apache.freemarker.core.util.WriteProtectable;
 import org.apache.freemarker.core.util._ClassUtil;
@@ -262,52 +261,6 @@ public class BeansWrapper implements RichObjectWrapper, WriteProtectable
{
      * @since 2.3.22
      */
     protected BeansWrapper(BeansWrapperConfiguration bwConf, boolean writeProtected, boolean
finalizeConstruction) {
-        // Backward-compatibility hack for "finetuneMethodAppearance" overrides to work:
-        if (bwConf.getMethodAppearanceFineTuner() == null) {
-            Class<?> thisClass = getClass();
-            boolean overridden = false;
-            boolean testFailed = false;
-            try {
-                while (!overridden
-                        && thisClass != DefaultObjectWrapper.class
-                        && thisClass != BeansWrapper.class
-                        && thisClass != SimpleObjectWrapper.class) {
-                    try {
-                        thisClass.getDeclaredMethod("finetuneMethodAppearance",
-                                new Class<?>[] { Class.class, Method.class, MethodAppearanceDecision.class
});
-                        overridden = true;
-                    } catch (NoSuchMethodException e) {
-                        thisClass = thisClass.getSuperclass();
-                    }
-                }
-            } catch (Throwable e) {
-                // The security manager sometimes doesn't allow this
-                LOG.info("Failed to check if finetuneMethodAppearance is overidden in {}"
-                        + "; acting like if it was, but this way it won't utilize the shared
class introspection "
-                        + "cache.", thisClass.getName(),
-                        e);
-                overridden = true;
-                testFailed = true;
-            }
-            if (overridden) {
-                if (!testFailed && !ftmaDeprecationWarnLogged) {
-                    LOG.warn("Overriding " + BeansWrapper.class.getName() + ".finetuneMethodAppearance
is deprecated "
-                            + "and will be banned sometimes in the future. Use setMethodAppearanceFineTuner
instead.");
-                    ftmaDeprecationWarnLogged = true;
-                }
-                bwConf = (BeansWrapperConfiguration) bwConf.clone(false);
-                bwConf.setMethodAppearanceFineTuner(new MethodAppearanceFineTuner() {
-
-                    @Override
-                    public void process(
-                            MethodAppearanceDecisionInput in, MethodAppearanceDecision out)
{
-                        finetuneMethodAppearance(in.getContainingClass(), in.getMethod(),
out);
-                    }
-                    
-                });
-            }
-        }
-
         incompatibleImprovements = bwConf.getIncompatibleImprovements();  // normalized
         
         simpleMapWrapper = bwConf.isSimpleMapWrapper();
@@ -1501,19 +1454,6 @@ public class BeansWrapper implements RichObjectWrapper, WriteProtectable
{
     }
     
     /**
-     * @deprecated Use {@link #setMethodAppearanceFineTuner(MethodAppearanceFineTuner)};
-     *     no need to extend this class anymore.
-     *     Soon this method will be final, so trying to override it will break your app.
-     *     Note that if the {@code methodAppearanceFineTuner} property is set to non-{@code
null}, this method is not
-     *     called anymore.
-     */
-    @Deprecated
-    protected void finetuneMethodAppearance(
-            Class<?> clazz, Method m, MethodAppearanceDecision decision) {
-        // left everything on its default; do nothing
-    }
-    
-    /**
      * Converts any {@link BigDecimal}s in the passed array to the type of
      * the corresponding formal argument of the method.
      */

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/f839a567/src/manual/en_US/FM3-CHANGE-LOG.txt
----------------------------------------------------------------------
diff --git a/src/manual/en_US/FM3-CHANGE-LOG.txt b/src/manual/en_US/FM3-CHANGE-LOG.txt
index 9992c17..891b5a8 100644
--- a/src/manual/en_US/FM3-CHANGE-LOG.txt
+++ b/src/manual/en_US/FM3-CHANGE-LOG.txt
@@ -98,4 +98,7 @@ the FreeMarer 3 changelog here:
 - Removed the deprecated BeansWrapper.nullModel setting. So null is always wrapped to null
now.
 - Removed several deprecated methods and constants. Some notes:
   - strict_bean_models configuration setting was removed, as it should be set on the BeansWrapper
itself
-  - .template_name now means the same as .current_template_name (it doesn't emulate 2.3 glitches
anymore)
\ No newline at end of file
+  - .template_name now means the same as .current_template_name (it doesn't emulate 2.3 glitches
anymore)
+  - Removed the deprecated BeansWrapper.nullModel setting. So null is always wrapped to null
now.
+  - Removed the overridable BeansWrapper.finetuneMethodAppearance method, which was deprecated
by the
+    finetuneMethodAppearance setting (BeansWrapper.setFinetuneMethodAppearance).

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/f839a567/src/test/java/org/apache/freemarker/core/model/impl/beans/FineTuneMethodAppearanceTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/freemarker/core/model/impl/beans/FineTuneMethodAppearanceTest.java
b/src/test/java/org/apache/freemarker/core/model/impl/beans/FineTuneMethodAppearanceTest.java
index 4f2dd55..fc828d8 100644
--- a/src/test/java/org/apache/freemarker/core/model/impl/beans/FineTuneMethodAppearanceTest.java
+++ b/src/test/java/org/apache/freemarker/core/model/impl/beans/FineTuneMethodAppearanceTest.java
@@ -19,10 +19,10 @@
 
 package org.apache.freemarker.core.model.impl.beans;
 
-import static org.junit.Assert.*;
-
-import java.lang.reflect.Method;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
 
+import org.apache.freemarker.core.Configuration;
 import org.apache.freemarker.core.model.TemplateHashModel;
 import org.apache.freemarker.core.model.TemplateMethodModelEx;
 import org.apache.freemarker.core.model.TemplateModel;
@@ -37,26 +37,8 @@ import org.junit.runners.JUnit4;
 public class FineTuneMethodAppearanceTest {
 
     @Test
-    public void detectNoOwerride() throws TemplateModelException {
-        assertNull(new DefaultObjectWrapper().getMethodAppearanceFineTuner());
-        assertNull(new DefaultObjectWrapperNoOverride().getMethodAppearanceFineTuner());
-        assertNull(new DefaultObjectWrapperNoOverrideExt().getMethodAppearanceFineTuner());
-    }
-    
-    @Test
-    public void legacyWayOfConfiguring() throws TemplateModelException {
-        DefaultObjectWrapper ow = new DefaultObjectWrapperOverride();
-        ow.setExposeFields(true);
-        checkIfProperlyWrapped(ow.wrap(new C()));
-        
-        ow = new DefaultObjectWrapperOverrideExt();
-        ow.setExposeFields(true);
-        checkIfProperlyWrapped(ow.wrap(new C()));
-    }
-
-    @Test
     public void newWayOfConfiguring() throws TemplateModelException {
-        DefaultObjectWrapper ow = new DefaultObjectWrapper();
+        DefaultObjectWrapper ow = new DefaultObjectWrapper(Configuration.VERSION_3_0_0);
         ow.setMethodAppearanceFineTuner(GetlessMethodsAsPropertyGettersRule.INSTANCE);
         ow.setExposeFields(true);
         checkIfProperlyWrapped(ow.wrap(new C()));
@@ -81,20 +63,4 @@ public class FineTuneMethodAppearanceTest {
         public String getV3() { return "getV3()"; }
     }
     
-    static class DefaultObjectWrapperNoOverride extends DefaultObjectWrapper {
-        
-    }
-
-    static class DefaultObjectWrapperNoOverrideExt extends DefaultObjectWrapperNoOverride
{ }
-    
-    static class DefaultObjectWrapperOverride extends DefaultObjectWrapper {
-
-        @Override
-        protected void finetuneMethodAppearance(Class clazz, Method m, MethodAppearanceDecision
out) {
-            GetlessMethodsAsPropertyGettersRule.INSTANCE.legacyProcess(clazz, m, out);
-        }
-        
-    }
-    
-    static class DefaultObjectWrapperOverrideExt extends DefaultObjectWrapperOverride { }
 }


Mime
View raw message