You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by he...@apache.org on 2020/01/16 13:39:33 UTC

[commons-jexl] 01/04: JEXL-318: added copy constructor Task #JEXL-318 - Annotation processing may fail in lexical mode

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

henrib pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jexl.git

commit bff5feb4e5680d8932155634e3adf989c8f17d8e
Author: henrib <he...@apache.org>
AuthorDate: Thu Jan 16 14:34:22 2020 +0100

    JEXL-318: added copy constructor
    Task #JEXL-318 - Annotation processing may fail in lexical mode
---
 .../org/apache/commons/jexl3/internal/LexicalFrame.java    | 10 ++++++++++
 .../org/apache/commons/jexl3/internal/LexicalScope.java    | 14 +++++++++++++-
 2 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/jexl3/internal/LexicalFrame.java b/src/main/java/org/apache/commons/jexl3/internal/LexicalFrame.java
index 4af5bff..6bb5f1e 100644
--- a/src/main/java/org/apache/commons/jexl3/internal/LexicalFrame.java
+++ b/src/main/java/org/apache/commons/jexl3/internal/LexicalFrame.java
@@ -37,6 +37,16 @@ public class LexicalFrame extends LexicalScope {
         super(previous);
         this.frame = scriptf;
     }
+    
+    /**
+     * Copy ctor.
+     * @param src the frame to copy
+     */
+    public LexicalFrame(LexicalFrame src) {
+        super(src.symbols, src.moreSymbols, src.previous);
+        frame = src.frame;
+        stack = src.stack != null? new ArrayDeque<Object>(src.stack) : null;
+    }
 
     /**
      * Declare the arguments.
diff --git a/src/main/java/org/apache/commons/jexl3/internal/LexicalScope.java b/src/main/java/org/apache/commons/jexl3/internal/LexicalScope.java
index 3ab83ad..bc2b6a8 100644
--- a/src/main/java/org/apache/commons/jexl3/internal/LexicalScope.java
+++ b/src/main/java/org/apache/commons/jexl3/internal/LexicalScope.java
@@ -40,12 +40,24 @@ public class LexicalScope {
     public LexicalScope(LexicalScope scope) {
         previous = scope;
     }
+        
+    /**
+     * Frame copy ctor base.
+     * @param s the symbols mask
+     * @param ms the more symbols bitset
+     * @param pscope the previous scope
+     */
+    protected LexicalScope(long s, BitSet ms, LexicalScope pscope) {
+        previous = pscope;
+        symbols = s;
+        moreSymbols = ms != null? (BitSet) ms.clone() : null;
+    }
 
     /**
      * Ensure more symbpls can be stored.
      * @return the set of more symbols
      */
-    final BitSet moreSymbols() {
+    protected final BitSet moreSymbols() {
         if (moreSymbols == null) {
             moreSymbols = new BitSet();
         }