Skip to content

[NETBEANS-4458] - enable use of generics#2194

Merged
matthiasblaesing merged 1 commit intoapache:masterfrom
BradWalker:enable_generics
Dec 11, 2020
Merged

[NETBEANS-4458] - enable use of generics#2194
matthiasblaesing merged 1 commit intoapache:masterfrom
BradWalker:enable_generics

Conversation

@BradWalker
Copy link
Member

A lot of places in the code has generic use commented out.. For example, the following in
LayoutModel.java

 public void unsetSameSize(List/*<String>*/ components, int dimension) {
    Iterator i = components.iterator();
    while (i.hasNext()) {
        String cid = (String)i.next();
        LayoutComponent lc = getLayoutComponent(cid);
        removeComponentFromLinkSizedGroup(lc, dimension);
    }
}

All I've done here is enable it to reduce the warnings and test out the code to make sure it works correctly.

Copy link
Contributor

@mklaehn mklaehn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

Copy link
Member

@neilcsmith-net neilcsmith-net left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1 as of now. This is not a compatible change. Needs proper review / plan, particularly for anything that is public API. @matthiasblaesing made this point already in #1377

@JaroslavTulach
Copy link

Many of the changes aren't API changes (like changing local variables and private or package private field/method types). Those can certainly be made, the other ones would deserve some more thoughts. We have just a single try to get the signatures right!

However let me state that it makes no sense to reduce number of warnings without preventing the warnings to ever appear again. E.g. for each module that you want to clean up, turn on "warning as error" mode and then fix (or suppress) all the warnings in the module. Otherwise it is just a useless mangling of the source code. In my 2 Kč opinion.

Copy link
Contributor

@matthiasblaesing matthiasblaesing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have nothing against fixing warnings, but I'd like to keep that separate from changing API. I marked two locations where I saw API, Jaroslav found another, so please check again, that only internal methods or fields are updated.
Friend modules are a bit of a stretch, while not API, I would not say they are fair game to change just because.

@BradWalker
Copy link
Member Author

Many of the changes aren't API changes (like changing local variables and private or package private field/method types). Those can certainly be made, the other ones would deserve some more thoughts. We have just a single try to get the signatures right!

However let me state that it makes no sense to reduce number of warnings without preventing the warnings to ever appear again. E.g. for each module that you want to clean up, turn on "warning as error" mode and then fix (or suppress) all the warnings in the module. Otherwise it is just a useless mangling of the source code. In my 2 Kč opinion.

I'm in agreement with you about this.. But, there are 10s of thousands of warnings.. I'm trying to fix things in a way that only "one thing" gets changed at a time.. That's why I'll do things like just fix the EMPTY_LIST..

I've managed to get our number of warnings down from approx. 26,000 to 19,000.. Once things get more manageable then we can start to turn on "error on warning"..

Hopefully this explains my rational better..

@BradWalker
Copy link
Member Author

One more thing.. I do try to stay away from API changes because of the previously mentioned comments. FYI..

Copy link
Contributor

@matthiasblaesing matthiasblaesing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry :-) I left two inline comments.

}

synchronized List /*<JavaClass>*/ createClassCollection() {
synchronized List/*<JavaClass>*/ createClassCollection() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is package private - I would not consider this API, so could be made generic and then the callsite of this function could be generified.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is package private - I would not consider this API, so could be made generic and then the callsite of this function could be generified.

Fixed..

//~ Instance fields ----------------------------------------------------------------------------------------------------------

protected List/*<Runnable>*/ afterBatchCommands = new ArrayList<>();
protected List<Runnable> afterBatchCommands = new ArrayList<>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a friend API.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a friend API.

fixed..

A lot of places in the code has generic use commented out.. For example, the following in
LayoutModel.java

     public void unsetSameSize(List/*<String>*/ components, int dimension) {
        Iterator i = components.iterator();
        while (i.hasNext()) {
            String cid = (String)i.next();
            LayoutComponent lc = getLayoutComponent(cid);
            removeComponentFromLinkSizedGroup(lc, dimension);
        }
    }

All I've done here is enable it to reduce the warnings and test out the code to make sure it works correctly.
@BradWalker
Copy link
Member Author

-1 as of now. This is not a compatible change. Needs proper review / plan, particularly for anything that is public API. @matthiasblaesing made this point already in #1377

Should be fixed..


private WizardDescriptor wizardDescriptor;

private final Set/*<ChangeListener>*/ listeners = new HashSet(1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HashSet of size 1 is probably a non-sense. By default it has 75% fill ratio and then it is rehashed.E.g. as soon as first item is added, the set is probably rehashed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HashSet of size 1 is probably a non-sense.

Just a follow-up comment in case someone comes across this bug report in the future.. I completely agree with your comment! My goal is simply to try and stay away from any "potential" source changes that could be behavioral. Even ones as small as this. Hope that explains why I do what I do..

@jtulach
Copy link
Contributor

jtulach commented Dec 11, 2020

The current state is integratable, as far as I can say.

Copy link
Contributor

@matthiasblaesing matthiasblaesing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks sane - lets get this in :-)

@matthiasblaesing matthiasblaesing merged commit 38172f4 into apache:master Dec 11, 2020
@junichi11 junichi11 added this to the 12.3 milestone Dec 12, 2020
@BradWalker BradWalker deleted the enable_generics branch December 14, 2020 16:14
@junichi11 junichi11 added the Code cleanup Label for cleanup done on the Netbeans IDE label Dec 14, 2020
@BradWalker
Copy link
Member Author

Hey @junichi11 , how can I add the "code cleanup" label? I don't seem to have permission..

@junichi11
Copy link
Member

junichi11 commented Dec 14, 2020

@BradWalker Well, only committer... So, if you would like to add a label, please ask someone (e.g. reviewer). I add it when I notice it is missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Code cleanup Label for cleanup done on the Netbeans IDE

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants