This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 120104 - Refactor -> "Move inner to outer level" rewrites some constant to different form
Summary: Refactor -> "Move inner to outer level" rewrites some constant to different form
Status: RESOLVED WONTFIX
Alias: None
Product: java
Classification: Unclassified
Component: Source (show other bugs)
Version: 6.x
Hardware: All All
: P4 blocker (vote)
Assignee: Rastislav Komara
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-10-25 22:39 UTC by Petr Nejedly
Modified: 2009-11-02 10:56 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Nejedly 2007-10-25 22:39:08 UTC
Try making outer class from "Inner" on this test case:

public class Main {
    public static class Inner {
        public static final int CONST = 1 << 23;
        private int val;

        public Inner(int val, boolean flag) {
            this.val = val | (flag ? 1<<30 : 0);
        }

        public int getVal() {
            return val & 0xBFFFFFFF;
        }
    }
}

It will rewrite the "0xBFFFFFFF" constant as "-1073741825, which, while being semantically equivalent, is harder to
understand in given context. The refacforing have once even rewritten "1<<30" as a numeric (and again hard to
understand) constant, but I can't reproduce this specific case with such a simple test case.

Keeping the numeric constants as they are is very important for readability of any code that deals with binary data.
Comment 1 Pavel Flaska 2007-10-30 11:33:11 UTC
Yes, that is bad. Unfortunately it is represented as an integer literal and when printed at a new place, there is no way
how to recognize the original notation. The problem is applicable for octal notation too. Bear in mind that this is
problem only when tree is inserted to the new file. During reformat, we have token sequence and we workaround this
problem. There isn't any good fix, this has to be fixed in serving (parser) side. Feel free to increase priority.

I do not have any idea of replacement 1<<30 as a numeric, this is a left shift expression, cannot find the place where
it can be replaced.
Comment 2 Rastislav Komara 2009-02-03 10:52:39 UTC
Overtake.
Comment 3 David Strupl 2009-03-31 15:56:13 UTC
Resolving all issues with milestone "future" as LATER. If you feel strongly that
it should be implemented please reopen and set the target milestone to "next".
Comment 4 Quality Engineering 2009-11-02 10:56:19 UTC
NetBeans.org Migration: changing resolution from LATER to WONTFIX