You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by rw...@apache.org on 2015/11/03 01:14:16 UTC

svn commit: r1712190 - in /pivot/branches/2.0.x: ./ core/src/org/apache/pivot/beans/BXMLSerializer.java

Author: rwhitcomb
Date: Tue Nov  3 00:14:16 2015
New Revision: 1712190

URL: http://svn.apache.org/viewvc?rev=1712190&view=rev
Log:
PIVOT-965: Fix another place where the "nashorn.global" object has to be
searched in order to find script variables defined when using Java 8.

The trick is that now script variables are a part of the Nashorn global
space, which is a sub-object of the regular namespace.  So, the additional
steps which are necessary in the case that a variable is not found would
be to then get the "nashorn.global" object, and if it exists transform
it into a "Bindings" (if possible) and then search for the value there.

Note: this fixes the particular case reported by user, but I'm pretty
sure there are other places that needs this same treatment.

This is a merge of revision 1712175 from trunk to branches/2.0.x.

Modified:
    pivot/branches/2.0.x/   (props changed)
    pivot/branches/2.0.x/core/src/org/apache/pivot/beans/BXMLSerializer.java

Propchange: pivot/branches/2.0.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Nov  3 00:14:16 2015
@@ -1 +1 @@
-/pivot/trunk:1346574,1347051,1394847,1394858,1398511,1399331,1401781,1405882,1407585,1409081,1410536,1410555,1417081,1417258,1428056,1428650,1435351,1436707,1438126,1438659,1444260,1444910,1502657,1510821,1516518,1519859,1522078,1523205,1523736,1523776,1525982,1526005,1536829,1537222,1604238,1610563,1611829,1614462,1624381,1675204,1675517,1678238,1678251,1687873-1687874,1688306,1688484,1688523,1691618
+/pivot/trunk:1346574,1347051,1394847,1394858,1398511,1399331,1401781,1405882,1407585,1409081,1410536,1410555,1417081,1417258,1428056,1428650,1435351,1436707,1438126,1438659,1444260,1444910,1502657,1510821,1516518,1519859,1522078,1523205,1523736,1523776,1525982,1526005,1536829,1537222,1604238,1610563,1611829,1614462,1624381,1675204,1675517,1678238,1678251,1687873-1687874,1688306,1688484,1688523,1691618,1712175

Modified: pivot/branches/2.0.x/core/src/org/apache/pivot/beans/BXMLSerializer.java
URL: http://svn.apache.org/viewvc/pivot/branches/2.0.x/core/src/org/apache/pivot/beans/BXMLSerializer.java?rev=1712190&r1=1712189&r2=1712190&view=diff
==============================================================================
--- pivot/branches/2.0.x/core/src/org/apache/pivot/beans/BXMLSerializer.java (original)
+++ pivot/branches/2.0.x/core/src/org/apache/pivot/beans/BXMLSerializer.java Tue Nov  3 00:14:16 2015
@@ -1105,11 +1105,25 @@ public class BXMLSerializer implements S
                                         if (value.equals(BXML_PREFIX + ":" + null)) {
                                             attribute.value = null;
                                         } else {
-                                            if (!JSON.containsKey(namespace, value)) {
-                                                throw new SerializationException("Value \"" + value + "\" is not defined.");
+                                            if (JSON.containsKey(namespace, value)) {
+                                                attribute.value = JSON.get(namespace, value);
+                                            } else {
+                                                Object nashornGlobal = namespace.get(NASHORN_GLOBAL);
+                                                if (nashornGlobal == null) {
+                                                    throw new SerializationException("Value \"" + value + "\" is not defined.");
+                                                } else {
+                                                    if (nashornGlobal instanceof Bindings) {
+                                                        Bindings bindings = (Bindings)nashornGlobal;
+                                                        if (bindings.containsKey(value)) {
+                                                            attribute.value = bindings.get(value);
+                                                        } else {
+                                                            throw new SerializationException("Value \"" + value + "\" is not defined.");
+                                                        }
+                                                    } else {
+                                                        throw new SerializationException("Value \"" + value + "\" is not defined.");
+                                                    }
+                                                }
                                             }
-
-                                            attribute.value = JSON.get(namespace, value);
                                         }
                                     }
                                 } else {