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/02 23:57:25 UTC
svn commit: r1712175 -
/pivot/trunk/core/src/org/apache/pivot/beans/BXMLSerializer.java
Author: rwhitcomb
Date: Mon Nov 2 22:57:25 2015
New Revision: 1712175
URL: http://svn.apache.org/viewvc?rev=1712175&view=rev
Log:
PIVOT-964: 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.
Modified:
pivot/trunk/core/src/org/apache/pivot/beans/BXMLSerializer.java
Modified: pivot/trunk/core/src/org/apache/pivot/beans/BXMLSerializer.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/beans/BXMLSerializer.java?rev=1712175&r1=1712174&r2=1712175&view=diff
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/beans/BXMLSerializer.java (original)
+++ pivot/trunk/core/src/org/apache/pivot/beans/BXMLSerializer.java Mon Nov 2 22:57:25 2015
@@ -1088,12 +1088,28 @@ 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 {