Anonymous | Login
Project:
RSS
  
News | My View | View Issues | Roadmap | Summary

View Issue DetailsJump to Notes ] Issue History ] Print ]
ID
0036834
TypeCategorySeverityReproducibilityDate SubmittedLast Update
defect[Openbravo ERP] A. Platformmajorhave not tried2017-09-12 09:032018-08-08 13:06
ReporteralostaleView Statuspublic 
Assigned Tocaristu 
PrioritynormalResolutionfixedFixed in Version3.0PR17Q4
StatusclosedFix in branchFixed in SCM revision5b7d3e960bd1
ProjectionnoneETAnoneTarget Version
OSAnyDatabaseAnyJava version8
OS VersionDatabase versionAnt version
Product VersionSCM revision 
Review Assigned Toalostale
Web browser
ModulesCore
Regression level
Regression date
Regression introduced in release
Regression introduced by commit
Triggers an Emergency PackNo
Summary

0036834: jre8: js defaults containing Dates fail

DescriptionWhen there is a default JavaScript value evaluated in server and it use JavaScript Date objects it fails when running in Java 8.
Steps To Reproduce1. 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)
Proposed SolutionIn 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.
TagsNo tags attached.
Attached Files

- Relationships Relation Graph ] Dependency Graph ]
related to feature request 0033035 closedairaceburu New filters in Purchase Order Report 
related to feature request 0031708 closedalostale support for JDK 8 
depends on backport 00368423.0PR17Q3 closedcaristu jre8: js defaults containing Dates fail 
depends on backport 00368433.0PR17Q2.4 closedcaristu jre8: js defaults containing Dates fail 
has duplicate defect 0037131 closedplatform Error trying getting defaults and Filter Expressions for process: cast jdk.nashorn.internal.objects.NativeDate to java.util.Date 
related to defect 0036882 closedcaristu There exists some old callouts in core still not refactored to SimpleCallout 
related to feature request 0038675 closedalostale Raise minimum stack Java version to Java 8 

-  Notes
(0099005)
hgbot (developer)
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 (developer)
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 (developer)
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 (developer)
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 (manager)
2017-09-14 13:38

reviewed

tested with java 7 and 8 in both cases working correctly
(0099043)
hgbot (developer)
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 (developer)
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 (developer)
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 (developer)
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 (developer)
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 (developer)
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 (developer)
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 (developer)
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 (developer)
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 (developer)
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

- Issue History
Date Modified Username Field Change
2017-09-12 09:03 alostale New Issue
2017-09-12 09:03 alostale Assigned To => platform
2017-09-12 09:03 alostale Modules => Core
2017-09-12 09:03 alostale Triggers an Emergency Pack => No
2017-09-12 09:04 alostale Relationship added related to 0033035
2017-09-12 09:04 alostale Relationship added related to 0031708
2017-09-12 09:04 alostale Status new => scheduled
2017-09-12 09:04 alostale Assigned To platform => caristu
2017-09-13 08:13 alostale Status scheduled => feedback
2017-09-13 08:13 alostale Status feedback => new
2017-09-13 08:14 alostale Status new => scheduled
2017-09-13 10:01 hgbot Checkin
2017-09-13 10:01 hgbot Note Added: 0099005
2017-09-13 10:04 hgbot Checkin
2017-09-13 10:04 hgbot Note Added: 0099006
2017-09-13 10:21 hgbot Checkin
2017-09-13 10:21 hgbot Note Added: 0099007
2017-09-13 10:21 hgbot Status scheduled => resolved
2017-09-13 10:21 hgbot Resolution open => fixed
2017-09-13 10:21 hgbot Fixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/5b7d3e960bd161c5c6219f69aac12c8bad3e4211 [^]
2017-09-13 10:21 caristu Review Assigned To => alostale
2017-09-13 10:38 hgbot Checkin
2017-09-13 10:38 hgbot Note Added: 0099009
2017-09-14 13:38 alostale Note Added: 0099041
2017-09-14 13:38 alostale Status resolved => closed
2017-09-14 13:38 alostale Fixed in Version => 3.0PR17Q4
2017-09-14 13:43 hgbot Checkin
2017-09-14 13:43 hgbot Note Added: 0099043
2017-09-20 16:15 caristu Relationship added duplicate of 0036882
2017-09-20 16:15 caristu Relationship deleted 0036882
2017-09-20 16:15 caristu Relationship added related to 0036882
2017-09-21 16:50 hudsonbot Checkin
2017-09-21 16:50 hudsonbot Note Added: 0099385
2017-09-21 16:50 hudsonbot Checkin
2017-09-21 16:50 hudsonbot Note Added: 0099386
2017-09-21 16:50 hudsonbot Checkin
2017-09-21 16:50 hudsonbot Note Added: 0099387
2017-09-21 16:50 hudsonbot Checkin
2017-09-21 16:50 hudsonbot Note Added: 0099388
2017-09-21 16:50 hudsonbot Checkin
2017-09-21 16:50 hudsonbot Note Added: 0099393
2017-10-20 11:18 caristu Relationship added has duplicate 0037131
2018-06-19 13:21 caristu Relationship added related to 0038675
2018-07-20 12:26 hgbot Checkin
2018-07-20 12:26 hgbot Note Added: 0105833
2018-07-20 12:26 hgbot Checkin
2018-07-20 12:26 hgbot Note Added: 0105834
2018-08-08 13:06 hudsonbot Checkin
2018-08-08 13:06 hudsonbot Note Added: 0106216
2018-08-08 13:06 hudsonbot Checkin
2018-08-08 13:06 hudsonbot Note Added: 0106217


Copyright © 2000 - 2009 MantisBT Group
Powered by Mantis Bugtracker