[ 
https://issues.apache.org/jira/browse/PDFBOX-2576?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14361071#comment-14361071
 ] 

Tilman Hausherr commented on PDFBOX-2576:
-----------------------------------------

What test failed? I'm wondering that eclipse might be right - changing
{code}
flags = ((int)buf[off] & 0xff) << 8 | (int)buf[off + 1] & 0xff;
{code}
to
{code}
flags = (buf[off] & 0xff) << 8 | buf[off + 1] & 0xff;
{code}
looks ok to me, because 0xff is already an int. But to be sure I tried this 
code with negative byte values:
{code}
        byte by1 = -3;
        byte by2 = -99;
        System.out.println("by = " + by1);
        System.out.println("by = " + (int) by1);
        System.out.println("by = " + (by1 & 0xff));
        System.out.println("by = " + ((int)by1 & 0xff));
        
        
        int x = (by1 & 0xff) << 8 | by2 & 0xff;
        System.out.println("x = " + x);
        int y = ((int)by1 & 0xff) << 8 | (int)by2 & 0xff;
        System.out.println("y = " + y);
{code}
The results are 
{code}
by = -3
by = -3
by = 253
by = 253
x = 64925
y = 64925
{code}
i.e. casting or not casting makes no difference.

> Improve code quality
> --------------------
>
>                 Key: PDFBOX-2576
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-2576
>             Project: PDFBox
>          Issue Type: Task
>    Affects Versions: 2.0.0
>            Reporter: Tilman Hausherr
>         Attachments: GraphicsOperatorProcessor.patch, 
> SecuryHandlerFactory.patch, 
> org.apache.pdfbox.contentstream.operator.state.patch, 
> pdfbox-override-patch.txt, pdfbox-raw-type-patch.txt, 
> pdfcloneutility-patch.txt, pdftextstripperbyarea-patch.txt, 
> ttfsubsetter-2.patch, ttfsubsetter-patch.txt
>
>
> This is a longterm issue for the task to improve code quality, by using the 
> [SonarQube 
> report|https://analysis.apache.org/dashboard/index/org.apache.pdfbox:pdfbox-reactor],
>  hints in different IDEs, the FindBugs tool and other code quality tools.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to