You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2020/06/24 00:17:50 UTC

[groovy] branch GROOVY_3_0_X updated: Trivial refactoring: extract constants

This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/GROOVY_3_0_X by this push:
     new bb09ad4  Trivial refactoring: extract constants
bb09ad4 is described below

commit bb09ad416aa3dda0e7920036685ecb56381ac128
Author: Daniel Sun <su...@apache.org>
AuthorDate: Wed Jun 24 08:15:22 2020 +0800

    Trivial refactoring: extract constants
    
    (cherry picked from commit 2925c859b4b670c31be4c92cad8f3769cce1efb9)
---
 src/main/java/org/codehaus/groovy/runtime/InvokerHelper.java | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/codehaus/groovy/runtime/InvokerHelper.java b/src/main/java/org/codehaus/groovy/runtime/InvokerHelper.java
index 64aedd0..197a848 100644
--- a/src/main/java/org/codehaus/groovy/runtime/InvokerHelper.java
+++ b/src/main/java/org/codehaus/groovy/runtime/InvokerHelper.java
@@ -87,6 +87,8 @@ public class InvokerHelper {
 
     public static final MetaClassRegistry metaRegistry = GroovySystem.getMetaClassRegistry();
     public static final String MAIN_METHOD_NAME = "main";
+    private static final String XMLUTIL_CLASS_FULL_NAME = "groovy.xml.XmlUtil";
+    private static final String SERIALIZE_METHOD_NAME = "serialize";
 
     public static void removeClass(Class clazz) {
         metaRegistry.removeMetaClass(clazz);
@@ -654,7 +656,7 @@ public class InvokerHelper {
         }
         if (arguments instanceof Element) {
             try {
-                Method serialize = Class.forName("groovy.xml.XmlUtil").getMethod("serialize", Element.class);
+                Method serialize = Class.forName(XMLUTIL_CLASS_FULL_NAME).getMethod(SERIALIZE_METHOD_NAME, Element.class);
                 return (String) serialize.invoke(null, arguments);
             } catch (ClassNotFoundException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
                 throw new RuntimeException(e);