poi-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 51175] New: [Patch] Proposal: Avoid Autoboxing
Date Mon, 09 May 2011 09:41:26 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=51175

             Bug #: 51175
           Summary: [Patch] Proposal: Avoid Autoboxing
           Product: POI
           Version: unspecified
          Platform: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XWPF
        AssignedTo: dev@poi.apache.org
        ReportedBy: stefan.stern@mind8.com
    Classification: Unclassified


Created attachment 26976
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=26976
Converts all occurrences of autoboxing / auto-unboxing into explicit
conversions.

As Autoboxing may cause some trouble during runtime, I propose to avoid it and
use explicit conversions where needed. An example line of code for
misunderstandings is this:

[code]
Integer index = 5;
List<ExampleObjects> list = getExampleList();
list.remove(index);
[/code]

One might expect to have element at index 5 removed from the list. But the API
will call the method with signature List#remove(Object), so nothing happens. 

If reading the code in terms of another issue, one can easily miss the
difference and wonder why on earth the element at index 5 was not removed. 

Therefore, I added explicit conversion whereever I found autoboxing takes place
in the XPWF classes. This includes a minor API change for two methods in
XWPFDocument, where "Integer" was used as return type, while "int" is
sufficient and fits better into the rest of the get-index-methods of XWPF.

Of course, this is a matter of coding style. So this just a proposal.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


Mime
View raw message