Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup raw type warnings related to WeakReference. #3923

Merged
merged 1 commit into from
Apr 5, 2022

Conversation

BradWalker
Copy link
Member

Cleanup raw type warnings related to WeakReference.

[repeat] /home/bwalker/src/netbeans/platform/openide.compat/src/org/openide/util/WeakListener.java:921: warning: [rawtypes] found raw type: WeakReference
[repeat] private static final class ListenerReference extends WeakReference implements Runnable {
[repeat] ^
[repeat] missing type arguments for generic class WeakReference
[repeat] where T is a type-variable:
[repeat] T extends Object declared in class WeakReference
[repeat] /home/bwalker/src/netbeans/platform/openide.compat/src/org/openide/util/WeakListener.java:922: warning: [rawtypes] found raw type: Class
[repeat] private static Class lastClass;
[repeat] ^
[repeat] missing type arguments for generic class Class
[repeat] where T is a type-variable:
[repeat] T extends Object declared in class Class

This work is done project wide. There are 3 remaining warnings that I was unable to get resolved. They will have to wait until later.


^Add meaningful description above

By opening a pull request you confirm that, unless explicitly stated otherwise, the changes -

  • are all your own work, and you have the right to contribute them.
  • are contributed solely under the terms and conditions of the Apache License 2.0 (see section 5 of the license for more information).

Please make sure (eg. git log) that all commits have a valid name and email address for you in the Author field.

If you're a first time contributor, see the Contributing guidelines for more information.

Copy link
Member

@mbien mbien 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

This work is done project wide.

thumbs up :)

There are 3 remaining warnings that I was unable to get resolved.

public API or some other reason? maybe we can solve this together?

@mbien mbien added this to the NB14 milestone Apr 4, 2022
@BradWalker
Copy link
Member Author

BradWalker commented Apr 4, 2022

There are 3 remaining warnings that I was unable to get resolved.

public API or some other reason? maybe we can solve this together?

I would certainly welcome the help. I just don't want to distract you from such "mundane work".. I could not figure out how to make the following API generic..

   [repeat] /home/bwalker/src/netbeans/platform/openide.compat/src/org/openide/util/WeakListener.java:921: warning: [rawtypes] found raw type: WeakReference
   [repeat]     private static final class ListenerReference extends WeakReference implements Runnable {
   [repeat]         
                                                 ^

If there was some way to fix this, I would welcome the help..

Maybe @jtulach might have a suggestion since he wrote this originally.

@mbien
Copy link
Member

mbien commented Apr 4, 2022

@BradWalker would this work?

diff --git a/platform/openide.compat/src/org/openide/util/WeakListener.java b/platform/openide.compat/src/org/openide/util/WeakListener.java
index 39f5210..ac5f3f3 100644
--- a/platform/openide.compat/src/org/openide/util/WeakListener.java
+++ b/platform/openide.compat/src/org/openide/util/WeakListener.java
@@ -918,14 +918,14 @@
 
     /** Reference that also holds ref to WeakListener.
     */
-    private static final class ListenerReference extends WeakReference implements Runnable {
+    private static final class ListenerReference<T> extends WeakReference<T> implements Runnable {
         private static Class lastClass;
         private static String lastMethodName;
         private static Method lastRemove;
         private static Object LOCK = new Object();
         final WeakListener weakListener;
 
-        public ListenerReference(Object ref, WeakListener weakListener) {
+        public ListenerReference(T ref, WeakListener weakListener) {
             super(ref, Utilities.activeReferenceQueue());
             this.weakListener = weakListener;
         }

   [repeat] /home/bwalker/src/netbeans/platform/openide.compat/src/org/openide/util/WeakListener.java:921: warning: [rawtypes] found raw type: WeakReference
   [repeat]     private static final class ListenerReference extends WeakReference implements Runnable {
   [repeat]                                                          ^
   [repeat]   missing type arguments for generic class WeakReference<T>
   [repeat]   where T is a type-variable:
   [repeat]     T extends Object declared in class WeakReference
   [repeat] /home/bwalker/src/netbeans/platform/openide.compat/src/org/openide/util/WeakListener.java:922: warning: [rawtypes] found raw type: Class
   [repeat]         private static Class lastClass;
   [repeat]                        ^
   [repeat]   missing type arguments for generic class Class<T>
   [repeat]   where T is a type-variable:
   [repeat]     T extends Object declared in class Class

This work is done project wide. There are 3 remaining warnings that I was unable to get resolved. They will have to wait until later.
@BradWalker BradWalker force-pushed the clean_weakreference_raw_type branch from 449f18f to 8d823d0 Compare April 5, 2022 01:50
@BradWalker
Copy link
Member Author

BradWalker commented Apr 5, 2022

@BradWalker would this work?

Hey @mbien , it did and provided the inspiration to nail down the stragglers. All references to raw type WeakReference are now cleaned up..

@mbien mbien added the Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) label Apr 5, 2022
@BradWalker BradWalker merged commit 04fc2a3 into apache:master Apr 5, 2022
@BradWalker BradWalker deleted the clean_weakreference_raw_type branch April 5, 2022 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code cleanup Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants