Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0036834Openbravo ERPA. Platformpublic2017-09-12 09:032018-08-08 13:06
alostale 
caristu 
normalmajorhave not tried
closedfixed 
5
 
3.0PR17Q4 
alostale
Core
No
0036834: jre8: js defaults containing Dates fail
When there is a default JavaScript value evaluated in server and it use JavaScript Date objects it fails when running in Java 8.
1. Open new Purchase Order Report
   -> ERROR:
      - Starting Date field is not defaulted (it should be default to today)
      - See openbravo.log:
ERROR org.openbravo.client.application.process.DefaultsProcessActionHandler - Error trying getting defaults and Filter Expressions for process: Cannot cast jdk.nashorn.internal.objects.NativeDate to java.util.Date
java.lang.ClassCastException: Cannot cast jdk.nashorn.internal.objects.NativeDate to java.util.Date
    at java.lang.invoke.MethodHandleImpl.newClassCastException(MethodHandleImpl.java:361)
    at java.lang.invoke.MethodHandleImpl.castReference(MethodHandleImpl.java:356)
    at jdk.nashorn.internal.scripts.Script$1$\^eval\_.:program(<eval>:1)
    at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:637)
    at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
    at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
    at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:449)
    at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:406)
    at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:402)
    at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:155)
    at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
    at org.openbravo.client.application.ParameterUtils.getJSExpressionResult(ParameterUtils.java:281)
    at org.openbravo.client.application.ParameterUtils.getParameterDefaultValue(ParameterUtils.java:220)
In Java 8 JavaScript engine was changed from Rhino to Nashorn. JavaScript Dates evaluated in server, returned a java.util.Date in Rhino, but with Nashorn they are evaluated to jdk.nashorn.internal.objects.NativeDate. It will be necessary to implement proper casting (through reflection?) to support both Java 7 and 8.
No tags attached.
related to feature request 0033035 closed airaceburu New filters in Purchase Order Report 
related to feature request 0031708 closed alostale support for JDK 8 
depends on backport 00368423.0PR17Q3 closed caristu jre8: js defaults containing Dates fail 
depends on backport 00368433.0PR17Q2.4 closed caristu jre8: js defaults containing Dates fail 
has duplicate defect 0037131 closed platform Error trying getting defaults and Filter Expressions for process: cast jdk.nashorn.internal.objects.NativeDate to java.util.Date 
related to defect 0036882 closed caristu There exists some old callouts in core still not refactored to SimpleCallout 
related to feature request 0038675 closed alostale Raise minimum stack Java version to Java 8 
Issue History
2017-09-12 09:03alostaleNew Issue
2017-09-12 09:03alostaleAssigned To => platform
2017-09-12 09:03alostaleModules => Core
2017-09-12 09:03alostaleTriggers an Emergency Pack => No
2017-09-12 09:04alostaleRelationship addedrelated to 0033035
2017-09-12 09:04alostaleRelationship addedrelated to 0031708
2017-09-12 09:04alostaleStatusnew => scheduled
2017-09-12 09:04alostaleAssigned Toplatform => caristu
2017-09-13 08:13alostaleStatusscheduled => feedback
2017-09-13 08:13alostaleStatusfeedback => new
2017-09-13 08:14alostaleStatusnew => scheduled
2017-09-13 10:01hgbotCheckin
2017-09-13 10:01hgbotNote Added: 0099005
2017-09-13 10:04hgbotCheckin
2017-09-13 10:04hgbotNote Added: 0099006
2017-09-13 10:21hgbotCheckin
2017-09-13 10:21hgbotNote Added: 0099007
2017-09-13 10:21hgbotStatusscheduled => resolved
2017-09-13 10:21hgbotResolutionopen => fixed
2017-09-13 10:21hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/5b7d3e960bd161c5c6219f69aac12c8bad3e4211 [^]
2017-09-13 10:21caristuReview Assigned To => alostale
2017-09-13 10:38hgbotCheckin
2017-09-13 10:38hgbotNote Added: 0099009
2017-09-14 13:38alostaleNote Added: 0099041
2017-09-14 13:38alostaleStatusresolved => closed
2017-09-14 13:38alostaleFixed in Version => 3.0PR17Q4
2017-09-14 13:43hgbotCheckin
2017-09-14 13:43hgbotNote Added: 0099043
2017-09-20 16:15caristuRelationship addedduplicate of 0036882
2017-09-20 16:15caristuRelationship deleted0036882
2017-09-20 16:15caristuRelationship addedrelated to 0036882
2017-09-21 16:50hudsonbotCheckin
2017-09-21 16:50hudsonbotNote Added: 0099385
2017-09-21 16:50hudsonbotCheckin
2017-09-21 16:50hudsonbotNote Added: 0099386
2017-09-21 16:50hudsonbotCheckin
2017-09-21 16:50hudsonbotNote Added: 0099387
2017-09-21 16:50hudsonbotCheckin
2017-09-21 16:50hudsonbotNote Added: 0099388
2017-09-21 16:50hudsonbotCheckin
2017-09-21 16:50hudsonbotNote Added: 0099393
2017-10-20 11:18caristuRelationship addedhas duplicate 0037131
2018-06-19 13:21caristuRelationship addedrelated to 0038675
2018-07-20 12:26hgbotCheckin
2018-07-20 12:26hgbotNote Added: 0105833
2018-07-20 12:26hgbotCheckin
2018-07-20 12:26hgbotNote Added: 0105834
2018-08-08 13:06hudsonbotCheckin
2018-08-08 13:06hudsonbotNote Added: 0106216
2018-08-08 13:06hudsonbotCheckin
2018-08-08 13:06hudsonbotNote Added: 0106217

Notes
(0099005)
hgbot   
2017-09-13 10:01   
Repository: erp/devel/pi
Changeset: c919c3df85385e28e75a9ada49fe51980d4106ce
Author: Carlos Aristu <carlos.aristu <at> openbravo.com>
Date: Wed Sep 13 09:59:56 2017 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/c919c3df85385e28e75a9ada49fe51980d4106ce [^]

related to issue 36834: Added test case for OBBindings

---
M src-test/src/org/openbravo/test/AllAntTaskTests.java
M src-test/src/org/openbravo/test/AllTests.java
M src-test/src/org/openbravo/test/AntTaskTests.java
A src-test/src/org/openbravo/test/expression/OBBindingsTest.java
---
(0099006)
hgbot   
2017-09-13 10:04   
Repository: erp/devel/pi
Changeset: 7ee008d11b6a4b6bd5c2136883e12e4645c8719e
Author: Carlos Aristu <carlos.aristu <at> openbravo.com>
Date: Wed Sep 13 10:03:47 2017 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/7ee008d11b6a4b6bd5c2136883e12e4645c8719e [^]

related to issue 36834: Removed unneeded test

---
M src-test/src/org/openbravo/test/expression/OBBindingsTest.java
---
(0099007)
hgbot   
2017-09-13 10:21   
Repository: erp/devel/pi
Changeset: 5b7d3e960bd161c5c6219f69aac12c8bad3e4211
Author: Carlos Aristu <carlos.aristu <at> openbravo.com>
Date: Wed Sep 13 10:17:23 2017 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/5b7d3e960bd161c5c6219f69aac12c8bad3e4211 [^]

fixes issue 36834: js defaults containing Dates fail in JRE8

  In Java 8 JavaScript engine was changed from Rhino to Nashorn. JavaScript Dates evaluated in server, returned a java.util.Date in Rhino, but with Nashorn they are evaluated to jdk.nashorn.internal.objects.NativeDate.

  This change caused a ClassCastException in JRE8 when invoking the methods of OBBindings which receive a java.util.Date as an argument. To fix the problem those methods have been overloaded by receiving an Object as argument. Therefore these methods will be invoked when working with JRE8, and we use reflection to retrieve the time information avoiding using classes which are not supported in JRE7.

---
M modules/org.openbravo.client.application/src/org/openbravo/client/application/OBBindings.java
---
(0099009)
hgbot   
2017-09-13 10:38   
Repository: erp/devel/pi
Changeset: 941a129396ad3229b028c9f35dd150cb2e3e0739
Author: Carlos Aristu <carlos.aristu <at> openbravo.com>
Date: Wed Sep 13 10:38:03 2017 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/941a129396ad3229b028c9f35dd150cb2e3e0739 [^]

related to issue 36834: Use correct test name in test suites

---
M src-test/src/org/openbravo/test/AllAntTaskTests.java
M src-test/src/org/openbravo/test/AllTests.java
M src-test/src/org/openbravo/test/AntTaskTests.java
---
(0099041)
alostale   
2017-09-14 13:38   
reviewed

tested with java 7 and 8 in both cases working correctly
(0099043)
hgbot   
2017-09-14 13:43   
Repository: erp/devel/pi
Changeset: 0602c527439bab32ce668f200ca81758c99cff73
Author: Carlos Aristu <carlos.aristu <at> openbravo.com>
Date: Thu Sep 14 13:42:22 2017 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/0602c527439bab32ce668f200ca81758c99cff73 [^]

related to issue 36834: added TODO comment

---
M modules/org.openbravo.client.application/src/org/openbravo/client/application/OBBindings.java
---
(0099385)
hudsonbot   
2017-09-21 16:50   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/9750b78d3e5c [^]
Maturity status: Test
(0099386)
hudsonbot   
2017-09-21 16:50   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/9750b78d3e5c [^]
Maturity status: Test
(0099387)
hudsonbot   
2017-09-21 16:50   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/9750b78d3e5c [^]
Maturity status: Test
(0099388)
hudsonbot   
2017-09-21 16:50   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/9750b78d3e5c [^]
Maturity status: Test
(0099393)
hudsonbot   
2017-09-21 16:50   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/9750b78d3e5c [^]
Maturity status: Test
(0105833)
hgbot   
2018-07-20 12:26   
Repository: erp/devel/pi
Changeset: c925911a5c0b828919db48dec7ba1b423be3179d
Author: Asier Lostalé <asier.lostale <at> openbravo.com>
Date: Wed Jul 11 09:03:01 2018 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/c925911a5c0b828919db48dec7ba1b423be3179d [^]

[jdk8] related to bug 36834: removed support for rhino JS engine

  There were some reflective code intented to support JS engines present in different
  JDK versions: Rhino in JDK <= 7 and Nashorn startinf from JDK 8.

  Notes:
   * Date JavaScript objects have been kept as Object rather than NativeDate
     (ie. formatDate(Object d)) because Nashorn NativeDate.getDate, API accepts
     Object because it checks whether it is in the JavaScript prototype hierarchy
     of JS Date.
   * We are relying on jdk.nashorn.internal package which can be somehow problematic,
     but as even NativeDate is in that package and we were in practice through
     reflection assuming the object was of that type, there should not be a real
     difference.
   * In JDK 11, Nashorn is deprecated for removal (JEP 335) with no alternative
     so far. Once actual removal occurs in some future JDK, this code will stop
     working.

---
M modules/org.openbravo.client.application/src/org/openbravo/client/application/OBBindings.java
---
(0105834)
hgbot   
2018-07-20 12:26   
Repository: erp/devel/pi
Changeset: 24c23f55ecef74986c8cc5a46d42230dfd5e14b0
Author: Asier Lostalé <asier.lostale <at> openbravo.com>
Date: Mon Jul 16 13:07:51 2018 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/24c23f55ecef74986c8cc5a46d42230dfd5e14b0 [^]

[jdk8] related to bug 36834: backed out changeset c925911a5c0b

  Even in JDK8, Nashorn's jdk.nashorn.internal.objects.NativeDate is publicly
  accessible, in JDK9+ it is in a closed module so not longer accessible API.

  We need to continue using reflection to make it work.

---
M modules/org.openbravo.client.application/src/org/openbravo/client/application/OBBindings.java
---
(0106216)
hudsonbot   
2018-08-08 13:06   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/bfd7a414183a [^]
Maturity status: Test
(0106217)
hudsonbot   
2018-08-08 13:06   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/bfd7a414183a [^]
Maturity status: Test