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

View Issue DetailsJump to Notes ] Issue History ] Print ]
ID
0037943
TypeCategorySeverityReproducibilityDate SubmittedLast Update
defect[Openbravo ERP] A. Platformminorhave not tried2018-02-15 18:552018-03-14 19:15
ReportercaristuView Statuspublic 
Assigned Tojarmendariz 
PriorityhighResolutionfixedFixed in Version3.0PR18Q2
StatusclosedFix in branchFixed in SCM revisiond526512e5e96
ProjectionnoneETAnoneTarget Version
OSAnyDatabaseAnyJava version
OS VersionDatabase versionAnt version
Product VersionSCM revision 
Review Assigned Tocaristu
Web browser
ModulesCore
Regression level
Regression date
Regression introduced in release
Regression introduced by commit
Triggers an Emergency PackNo
Summary

0037943: JDK 9: remove [deprecation] newInstance() in Class warnings

DescriptionWhen building Openbravo with JDK 9, several "[deprecation] newInstance() in Class" warnings appears:

warning: [deprecation] newInstance() in Class has been deprecated

Besides, it seems that is not a recommended practice to make use of this method. So, these warnings should be fixed by retrieving the instance from a constructor object. See [1] and [2].

This is a safe change as Class.newInstance() is more limited than Constructor.newInstance(): the first one can only invoke the zero-argument constructor, while the second one may invoke any constructor. So, in order to fix this issue we have just to:

a) Replace calls to Class.newInstance() with Constructor.newInstance() without using any argument.
b) Catch the new exception types that are thrown by Constructor.newInstance(): InvocationTargetException and NoSuchMethodException. Both of these exception types are subclasses of ReflectiveOperationException.

[1] https://docs.oracle.com/javase/9/docs/api/java/lang/Class.html [^]
[2] https://docs.oracle.com/javase/tutorial/reflect/member/ctorInstance.html [^]
Steps To Reproduce1. Build Openbravo with Java 9
  -> Check warnings
TagsApproved
Attached Filesdiff file icon newInstanceRemovalFinal.diff [^] (9,921 bytes) 2018-02-26 18:22 [Show Content]
patch file icon new-instance.patch [^] (57,381 bytes) 2018-03-07 13:53 [Show Content]

- Relationships Relation Graph ] Dependency Graph ]
related to feature request 0037083 closedalostale Openbravo ERP support JDK 9 
related to defect 0038000 closedjarmendariz Openbravo ERP API change for ExternalConnectionPool.getInstance(String) method due to [deprecation] newInstance() warning removal 
related to defect 0038095 closedjarmendariz Modules Handle new Exceptions thrown by ExternalConnectionPool.getInstance 
related to defect 0038115 closedjarmendariz Retail Modules JDK 9: Remove newInstance() deprecation warnings 

-  Notes
(0103178)
hgbot (developer)
2018-03-13 09:48

Repository: erp/devel/pi
Changeset: d526512e5e96cb6c5acf77a8451b82f233e4dd0c
Author: Javier Armendáriz <javier.armendariz <at> openbravo.com>
Date: Fri Mar 09 14:18:48 2018 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/d526512e5e96cb6c5acf77a8451b82f233e4dd0c [^]

Fixed issue 37943: Removed newInstance() deprecation warnings.

Class.newInstance() is deprecated from JDK 9. It is replaced by Class.getDeclaredConstructor().newInstance(),
but it has the drawback that this call throws an instance of ReflectiveOperationException that must be taken
into account.

---
M modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/ad_actionbutton/ImportBankFile.java
M modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_ExecutePayment.java
M modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/utility/FIN_MatchingTransaction.java
M modules/org.openbravo.client.application/src/org/openbravo/client/application/OBBindings.java
M modules/org.openbravo.client.application/src/org/openbravo/client/application/window/FormInitializationComponent.java
M modules/org.openbravo.client.kernel/src/org/openbravo/client/kernel/reference/UIDefinitionController.java
M modules/org.openbravo.service.datasource/src/org/openbravo/service/datasource/DataSourceProperty.java
M src-core/src/org/openbravo/base/HttpBaseServlet.java
M src-core/src/org/openbravo/buildvalidation/BuildValidationHandler.java
M src-core/src/org/openbravo/database/ExternalConnectionPool.java
M src-core/src/org/openbravo/modulescript/ModuleScriptHandler.java
M src-wad/src/org/openbravo/wad/WadUtility.java
M src/org/openbravo/authentication/AuthenticationManager.java
M src/org/openbravo/base/model/ModelProvider.java
M src/org/openbravo/base/model/Reference.java
M src/org/openbravo/base/provider/OBProvider.java
M src/org/openbravo/costing/CostingServer.java
M src/org/openbravo/erpCommon/ad_forms/AcctServer.java
M src/org/openbravo/erpCommon/ad_forms/DocAmortization.java
M src/org/openbravo/erpCommon/ad_forms/DocBank.java
M src/org/openbravo/erpCommon/ad_forms/DocCash.java
M src/org/openbravo/erpCommon/ad_forms/DocCostAdjustment.java
M src/org/openbravo/erpCommon/ad_forms/DocDPManagement.java
M src/org/openbravo/erpCommon/ad_forms/DocDoubtfulDebt.java
M src/org/openbravo/erpCommon/ad_forms/DocFINBankStatement.java
M src/org/openbravo/erpCommon/ad_forms/DocFINFinAccTransaction.java
M src/org/openbravo/erpCommon/ad_forms/DocFINPayment.java
M src/org/openbravo/erpCommon/ad_forms/DocFINReconciliation.java
M src/org/openbravo/erpCommon/ad_forms/DocGLJournal.java
M src/org/openbravo/erpCommon/ad_forms/DocInOut.java
M src/org/openbravo/erpCommon/ad_forms/DocInternalConsumption.java
M src/org/openbravo/erpCommon/ad_forms/DocInventory.java
M src/org/openbravo/erpCommon/ad_forms/DocInvoice.java
M src/org/openbravo/erpCommon/ad_forms/DocLCCost.java
M src/org/openbravo/erpCommon/ad_forms/DocLandedCost.java
M src/org/openbravo/erpCommon/ad_forms/DocMatchInv.java
M src/org/openbravo/erpCommon/ad_forms/DocMovement.java
M src/org/openbravo/erpCommon/ad_forms/DocOrder.java
M src/org/openbravo/erpCommon/ad_forms/DocPayment.java
M src/org/openbravo/erpCommon/ad_forms/DocProduction.java
M src/org/openbravo/erpCommon/utility/GenericTreeServlet.java
M src/org/openbravo/erpCommon/utility/OBMessageUtils.java
M src/org/openbravo/scheduling/DefaultJob.java
---
(0103216)
hudsonbot (developer)
2018-03-13 17:24

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/1d3ccc92fab6 [^]
Maturity status: Test
(0103251)
caristu (developer)
2018-03-14 19:15

Code reviewed + tested OK.

- Issue History
Date Modified Username Field Change
2018-02-15 18:55 caristu New Issue
2018-02-15 18:55 caristu Assigned To => platform
2018-02-15 18:55 caristu Modules => Core
2018-02-15 18:55 caristu Triggers an Emergency Pack => No
2018-02-15 18:55 caristu Issue generated from 0037942
2018-02-15 18:55 caristu Relationship added related to 0037083
2018-02-15 19:04 caristu Description Updated View Revisions
2018-02-16 09:19 caristu Summary JDK: remove [deprecation] newInstance() in Class warnings => JDK 9: remove [deprecation] newInstance() in Class warnings
2018-02-26 13:41 caristu Relationship added related to 0038000
2018-02-26 13:51 caristu Description Updated View Revisions
2018-02-26 13:51 caristu Description Updated View Revisions
2018-02-26 13:52 caristu Description Updated View Revisions
2018-02-26 18:22 caristu File Added: newInstanceRemovalFinal.diff
2018-03-07 13:53 jarmendariz File Added: new-instance.patch
2018-03-09 14:34 jarmendariz Relationship added related to 0038095
2018-03-12 12:13 jarmendariz Assigned To platform => jarmendariz
2018-03-12 12:13 alostale Tag Attached: Approved
2018-03-12 12:40 jarmendariz Status new => scheduled
2018-03-13 09:48 hgbot Checkin
2018-03-13 09:48 hgbot Note Added: 0103178
2018-03-13 09:48 hgbot Status scheduled => resolved
2018-03-13 09:48 hgbot Resolution open => fixed
2018-03-13 09:48 hgbot Fixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/d526512e5e96cb6c5acf77a8451b82f233e4dd0c [^]
2018-03-13 09:50 jarmendariz Review Assigned To => caristu
2018-03-13 13:20 jarmendariz Relationship added related to 0038115
2018-03-13 17:24 hudsonbot Checkin
2018-03-13 17:24 hudsonbot Note Added: 0103216
2018-03-14 19:15 caristu Note Added: 0103251
2018-03-14 19:15 caristu Status resolved => closed
2018-03-14 19:15 caristu Fixed in Version => 3.0PR18Q2


Copyright © 2000 - 2009 MantisBT Group
Powered by Mantis Bugtracker