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 271736 - Wrong "not used" hint
Summary: Wrong "not used" hint
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 8.2
Hardware: PC Windows 10 x64
: P2 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-31 08:03 UTC by ileasile
Modified: 2017-12-27 01:08 UTC (History)
1 user (show)

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 ileasile 2017-10-31 08:03:19 UTC
I am getting "not used" hint in the following code:

public interface JsonValueEnumConverter<E extends Enum<E>> extends JsonValueConverter<Integer>{
    
    JsonValueEnumConverter<PatternBreakoutType> PATTERN_BREAKOUT_CONV = new JsonValueEnumConverter<PatternBreakoutType>() {
        @Override
        public Integer convert(JsonValue val) {
            JsonArray ar = ((JsonArray) val); // here
            int result = 0; // here
            for(int i = 0 /* even here*/; i<ar.size(); ++i){
                result += UtilityMath.intPow(2, Enum.valueOf(PatternBreakoutType.class, ar.getString(i)).getCode());
            }
            return result;
        }

        @Override
        public JsonValue back_convert(Integer val) {
            JsonArrayBuilder res = Json.createArrayBuilder(); //and here

            for(PatternBreakoutType e: PatternBreakoutType.values() ){
                if(UtilityMath.getBit(val, e.getCode())){
                    res.add(e.name());
                }
            }

            return res.build();
        }
    };
}

Project code compiles, and I have no unresolved hints/warnings in other project files.
Comment 1 dtrebbien 2017-11-08 14:30:37 UTC
I have created a pull request to fix this issue: https://github.com/apache/incubator-netbeans/pull/258
Comment 2 dtrebbien 2017-12-27 01:08:00 UTC
Closing as PR 258 has been merged.