svn commit: r1817960 - /pivot/trunk/core/src/org/apache/pivot/beans/BXMLSerializer.java
Author: rwhitcomb Date: Tue Dec 12 21:59:28 2017 New Revision: 1817960 URL: http://svn.apache.org/viewvc?rev=1817960&view=rev Log: PIVOT-965: Fix the problem introduced by earlier changes that caused two or more listener list callbacks to overwrite earlier ones, causing the wrong callback to be invoked. Solution is to create a new engine for each callback function defined, so they are unique. 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=1817960&r1=1817959&r2=1817960&view=diff == --- pivot/trunk/core/src/org/apache/pivot/beans/BXMLSerializer.java (original) +++ pivot/trunk/core/src/org/apache/pivot/beans/BXMLSerializer.java Tue Dec 12 21:59:28 2017 @@ -109,7 +109,7 @@ public class BXMLSerializer implements S /*private static void printBindings(String message, java.util.Map bindings) { System.out.format("= %1$s =%n", message); -System.out.format("--- Bindings %1$s [%2$s] ---%n", bindings, bindings.getClass().getName()); +System.out.format("--- Bindings %1$s=%2$s ---%n", bindings, bindings.getClass().getName()); for (String key : bindings.keySet()) { Object value = bindings.get(key); System.out.format("key: %1$s, value: %2$s [%3$s]%n", key, value, Integer.toHexString(System.identityHashCode(value))); @@ -361,6 +361,30 @@ public class BXMLSerializer implements S fileExtensions.put(PropertiesSerializer.PROPERTIES_EXTENSION, PropertiesSerializer.MIME_TYPE); } +private ScriptEngine newEngineByName(String scriptLanguage) +throws SerializationException +{ +ScriptEngine engine = scriptEngineManager.getEngineByName(scriptLanguage); + +if (engine == null) { +throw new SerializationException("Unable to find scripting engine for" ++ " language \"" + scriptLanguage + "\"."); +} + +// NOTE: this might not be right for Rhino engine, but works for Nashorn +engine.setBindings(bindings, ScriptContext.GLOBAL_SCOPE); +if (engine.getFactory().getNames().contains("javascript")) { +try { +engine.eval(NASHORN_COMPAT_SCRIPT); +} catch (ScriptException se) { +throw new SerializationException("Unable to execute Nashorn compatibility script:", +se); +} +} + +return engine; +} + /** * Get a script engine instance for the given script language (typically "JavaScript"). * Two things happen for a new script engine: set the global bindings to our @@ -383,23 +407,7 @@ public class BXMLSerializer implements S return engine; } -engine = scriptEngineManager.getEngineByName(scriptLanguage); - -if (engine == null) { -throw new SerializationException("Unable to find scripting engine for" -+ " language \"" + scriptLanguage + "\"."); -} - -// NOTE: this might not be right for Rhino engine, but works for Nashorn -engine.setBindings(bindings, ScriptContext.GLOBAL_SCOPE); -if (engine.getFactory().getNames().contains("javascript")) { -try { -engine.eval(NASHORN_COMPAT_SCRIPT); -} catch (ScriptException se) { -throw new SerializationException("Unable to execute Nashorn compatibility script:", -se); -} -} +engine = newEngineByName(scriptLanguage); scriptEngines.put(languageKey, engine); @@ -1072,8 +1080,7 @@ public class BXMLSerializer implements S Class propertyClass = null; if (Character.isUpperCase(localName.charAt(0))) { -// The attribute represents a static property or -// listener list +// The attribute represents a static property or listener list int j = localName.indexOf('.'); name = localName.substring(j + 1); @@ -1273,13 +1280,11 @@ public class BXMLSerializer implements S if (element.parent != null) { if (element.parent.type == Element.Type.WRITABLE_PROPERTY) { // Set this as the property value; it will be applied -// later in the -// parent's closing tag +// later in the parent's closing tag element.parent.value = element.value; } else if (element.parent.value != null) { // If the parent element has a default property, use it; -// ot
svn commit: r1817955 - /pivot/trunk/core/src/org/apache/pivot/beans/BeanMonitor.java
Author: rwhitcomb Date: Tue Dec 12 19:59:09 2017 New Revision: 1817955 URL: http://svn.apache.org/viewvc?rev=1817955&view=rev Log: Some of the cleanup done to BeanMonitor actually broke the functionality of script bind mapping from one attribute to another, because there was a "break;" added after the first "ListenerList" "get" was found, instead of going through every listener list as is really required. Modified: pivot/trunk/core/src/org/apache/pivot/beans/BeanMonitor.java Modified: pivot/trunk/core/src/org/apache/pivot/beans/BeanMonitor.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/beans/BeanMonitor.java?rev=1817955&r1=1817954&r2=1817955&view=diff == --- pivot/trunk/core/src/org/apache/pivot/beans/BeanMonitor.java (original) +++ pivot/trunk/core/src/org/apache/pivot/beans/BeanMonitor.java Tue Dec 12 19:59:09 2017 @@ -199,8 +199,6 @@ public class BeanMonitor { } catch (IllegalAccessException | InvocationTargetException exception) { throw new RuntimeException(exception); } - -break; } } }
svn commit: r1817938 - /pivot/trunk/core/test/org/apache/pivot/util/test/VersionTest.java
Author: rwhitcomb Date: Tue Dec 12 17:30:11 2017 New Revision: 1817938 URL: http://svn.apache.org/viewvc?rev=1817938&view=rev Log: PIVOT-1016: Add tests of all the other potential new Java version strings found in the JEP-223 paper, just as a final check. Modified: pivot/trunk/core/test/org/apache/pivot/util/test/VersionTest.java Modified: pivot/trunk/core/test/org/apache/pivot/util/test/VersionTest.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/test/org/apache/pivot/util/test/VersionTest.java?rev=1817938&r1=1817937&r2=1817938&view=diff == --- pivot/trunk/core/test/org/apache/pivot/util/test/VersionTest.java (original) +++ pivot/trunk/core/test/org/apache/pivot/util/test/VersionTest.java Tue Dec 12 17:30:11 2017 @@ -129,6 +129,42 @@ public class VersionTest { String newJava10Formatted = newJava10.toString(); System.out.format("Potential new Java 10 version: %1$s, parsed and formatted: %2$s%n", newJava10Version, newJava10Formatted); assertEquals(newJava10Formatted, "10.0.0_00--ea"); +} + +@Test +public void testJava9Versions() { +// All the other suggested versions from "http://openjdk.java.net/jeps/223"; +String[] versions = { +"9-ea+19", +"9+100", +"9.0.1+20", +"9.0.2+12", +"9.1.2+62", +"9.1.3+15", +"9.1.4+8", +"9.2.4+45", +"7.4.10+11", +"7.4.11+15", +"7.5.11+43", +"7.5.12+18", +"7.5.13+13", +"7.5.14+13", +"7.6.14+19", +"7.6.15+20", +"9-ea", +"9-ea+73", +"9+100", +"9", +"9.1.2", +"9.1.2+62", +"9.0.1", +"9.0.1+20" +}; +// Just make sure we don't throw or get other errors decoding all these +for (String version : versions) { +Version v = Version.decode(version); +System.out.format("Raw %1$s -> %2$s%n", version, v.toString()); +} } }
svn commit: r1817937 - in /pivot/trunk/core: src/org/apache/pivot/util/Version.java test/org/apache/pivot/util/test/VersionTest.java
Author: rwhitcomb Date: Tue Dec 12 17:09:36 2017 New Revision: 1817937 URL: http://svn.apache.org/viewvc?rev=1817937&view=rev Log: PIVOT-1016: Add more another likely to fail tests of Version parsing taken from the JEP-223 full discussion to make sure we will safely parse these variants. So, had to make some parsing changes in "Version.decode()" for these new variants to work (or at least to parse successfully). Modified: pivot/trunk/core/src/org/apache/pivot/util/Version.java pivot/trunk/core/test/org/apache/pivot/util/test/VersionTest.java Modified: pivot/trunk/core/src/org/apache/pivot/util/Version.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/util/Version.java?rev=1817937&r1=1817936&r2=1817937&view=diff == --- pivot/trunk/core/src/org/apache/pivot/util/Version.java (original) +++ pivot/trunk/core/src/org/apache/pivot/util/Version.java Tue Dec 12 17:09:36 2017 @@ -116,18 +116,13 @@ public class Version implements Comparab String revision; // Some "version" strings separate fields with a space // While Java 9 uses a new scheme where "build" uses a "+" -int i = string.indexOf(" "); -if (i == -1) { -i = string.indexOf("-"); -} -if (i == -1) { -i = string.indexOf("+"); -} -if (i == -1) { +String parts[] = string.split("[ +\\-]"); +if (parts.length == 1) { revision = string; } else { -revision = string.substring(0, i); -build = string.substring(i + 1); +int len = parts[0].length(); +revision = string.substring(0, len); +build = string.substring(len + 1); } String[] revisionNumbers = revision.split("\\."); Modified: pivot/trunk/core/test/org/apache/pivot/util/test/VersionTest.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/test/org/apache/pivot/util/test/VersionTest.java?rev=1817937&r1=1817936&r2=1817937&view=diff == --- pivot/trunk/core/test/org/apache/pivot/util/test/VersionTest.java (original) +++ pivot/trunk/core/test/org/apache/pivot/util/test/VersionTest.java Tue Dec 12 17:09:36 2017 @@ -117,5 +117,18 @@ public class VersionTest { String formattedJavaVersion = javaVersion.toString(); System.out.format("Java Runtime version (parsed and formatted): %1$s, raw: %2$s%n", formattedJavaVersion, sysJavaVersion); assertEquals("Java Runtime version", sysJavaVersion, formattedJavaVersion); + +String newJava9Version = "9-ea+19"; +Version newJava9 = Version.decode(newJava9Version); +String newJava9Formatted = newJava9.toString(); +System.out.format("Potential new Java version: %1$s, parsed and formatted: %2$s%n", newJava9Version, newJava9Formatted); +assertEquals(newJava9Formatted, "9.0.0_00-ea+19"); + +String newJava10Version = "10+-ea"; +Version newJava10 = Version.decode(newJava10Version); +String newJava10Formatted = newJava10.toString(); +System.out.format("Potential new Java 10 version: %1$s, parsed and formatted: %2$s%n", newJava10Version, newJava10Formatted); +assertEquals(newJava10Formatted, "10.0.0_00--ea"); + } }
svn commit: r1817927 - in /pivot/trunk/core: src/org/apache/pivot/util/Version.java test/org/apache/pivot/util/test/VersionTest.java
Author: rwhitcomb Date: Tue Dec 12 16:19:34 2017 New Revision: 1817927 URL: http://svn.apache.org/viewvc?rev=1817927&view=rev Log: PIVOT-1016: Introduce minimal version parsing changes so that at least the current Java 9 version string will parse without errors. The Version.toString() won't recover the initial string correctly, although all the information parsed is available. Add a simple test for the current Java 9 version string. Modified: pivot/trunk/core/src/org/apache/pivot/util/Version.java pivot/trunk/core/test/org/apache/pivot/util/test/VersionTest.java Modified: pivot/trunk/core/src/org/apache/pivot/util/Version.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/util/Version.java?rev=1817927&r1=1817926&r2=1817927&view=diff == --- pivot/trunk/core/src/org/apache/pivot/util/Version.java (original) +++ pivot/trunk/core/src/org/apache/pivot/util/Version.java Tue Dec 12 16:19:34 2017 @@ -115,11 +115,15 @@ public class Version implements Comparab String revision; // Some "version" strings separate fields with a space +// While Java 9 uses a new scheme where "build" uses a "+" int i = string.indexOf(" "); if (i == -1) { i = string.indexOf("-"); } if (i == -1) { +i = string.indexOf("+"); +} +if (i == -1) { revision = string; } else { revision = string.substring(0, i); @@ -135,7 +139,7 @@ public class Version implements Comparab minorRevision = Short.parseShort(revisionNumbers[1]); if (revisionNumbers.length > 2) { -String[] maintenanceRevisionNumbers = revisionNumbers[2].split("_"); +String[] maintenanceRevisionNumbers = revisionNumbers[2].split("[_\\-]"); if (maintenanceRevisionNumbers.length > 0) { maintenanceRevision = Short.parseShort(maintenanceRevisionNumbers[0]); Modified: pivot/trunk/core/test/org/apache/pivot/util/test/VersionTest.java URL: http://svn.apache.org/viewvc/pivot/trunk/core/test/org/apache/pivot/util/test/VersionTest.java?rev=1817927&r1=1817926&r2=1817927&view=diff == --- pivot/trunk/core/test/org/apache/pivot/util/test/VersionTest.java (original) +++ pivot/trunk/core/test/org/apache/pivot/util/test/VersionTest.java Tue Dec 12 16:19:34 2017 @@ -64,6 +64,13 @@ public class VersionTest { Version v1_0 = new Version(1, 0, 0, 0); assertEquals("version 0 decode", v0, v1_0); assertEquals("version 0 to string", v1_0.toString(), s1_0_0); + +// New Java 9 version number scheme +String j9 = "9.0.1+11"; +Version vj9 = Version.decode(j9); +Version vj9_0 = new Version(9, 0, 1, 0); +assertEquals("Java version 9 decode", vj9, vj9_0); +assertEquals("Java version 9 to string", vj9.toString(), "9.0.1_00-11"); } @Test