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

Summary: Wrong "not used" hint
Product: java Reporter: ileasile
Component: HintsAssignee: Svata Dedic <sdedic>
Status: RESOLVED FIXED    
Severity: normal CC: dtrebbien
Priority: P2    
Version: 8.2   
Hardware: PC   
OS: Windows 10 x64   
Issue Type: DEFECT Exception Reporter:

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.