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

View Issue DetailsJump to Notes ] Issue History ] Print ]
ID
0036842
TypeCategorySeverityReproducibilityDate SubmittedLast Update
backport[Openbravo ERP] A. Platformmajorhave not tried2017-09-12 09:032017-09-14 13:39
ReporteralostaleView Statuspublic 
Assigned Tocaristu 
PrioritynormalResolutionfixedFixed in Version3.0PR17Q3
StatusclosedFix in branchFixed in SCM revision415490026f05
ProjectionnoneETAnoneTarget Version3.0PR17Q3
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

0036842: 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 ]
blocks defect 0036834 closedcaristu jre8: js defaults containing Dates fail 

-  Notes
(0099008)
hgbot (developer)
2017-09-13 10:25

Repository: erp/backports/3.0PR17Q3
Changeset: 415490026f0582e63aca0fedf1b348d71b2e97ab
Author: Carlos Aristu <carlos.aristu <at> openbravo.com>
Date: Wed Sep 13 10:24:26 2017 +0200
URL: http://code.openbravo.com/erp/backports/3.0PR17Q3/rev/415490026f0582e63aca0fedf1b348d71b2e97ab [^]

fixes issue 36842: 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
---
(0099042)
alostale (developer)
2017-09-14 13:39

reviewed

tested with java 7 and 8 in both cases working correctly

- Issue History
Date Modified Username Field Change
2017-09-13 08:14 alostale Type defect => backport
2017-09-13 08:14 alostale Target Version => 3.0PR17Q3
2017-09-13 10:25 hgbot Checkin
2017-09-13 10:25 hgbot Note Added: 0099008
2017-09-13 10:25 hgbot Status scheduled => resolved
2017-09-13 10:25 hgbot Resolution open => fixed
2017-09-13 10:25 hgbot Fixed in SCM revision => http://code.openbravo.com/erp/backports/3.0PR17Q3/rev/415490026f0582e63aca0fedf1b348d71b2e97ab [^]
2017-09-13 10:25 caristu Review Assigned To => alostale
2017-09-14 13:39 alostale Note Added: 0099042
2017-09-14 13:39 alostale Status resolved => closed
2017-09-14 13:39 alostale Fixed in Version => 3.0PR17Q3


Copyright © 2000 - 2009 MantisBT Group
Powered by Mantis Bugtracker