You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by mk...@apache.org on 2019/12/09 23:50:13 UTC

[netbeans] branch master updated: [NETBEANS-3533] Corrected compiler warnings in Classpath APIs project fixed compiler warnings

This is an automated email from the ASF dual-hosted git repository.

mklaehn pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git


The following commit(s) were added to refs/heads/master by this push:
     new dcd52fa  [NETBEANS-3533] Corrected compiler warnings in Classpath APIs project fixed compiler warnings
dcd52fa is described below

commit dcd52fa87868d2f5cbc38263034536e080eea597
Author: Martin Klähn <mk...@apache.org>
AuthorDate: Tue Dec 3 21:51:38 2019 +0100

    [NETBEANS-3533] Corrected compiler warnings in Classpath APIs project
    fixed compiler warnings
---
 .../org/netbeans/api/java/classpath/ClassLoaderSupport.java | 13 +++++++------
 .../org/netbeans/api/java/queries/BinaryForSourceQuery.java |  4 ++--
 .../netbeans/modules/java/classpath/ClassPathAccessor.java  |  2 +-
 .../src/org/netbeans/api/java/classpath/ClassPathTest.java  |  6 +++---
 .../netbeans/api/java/queries/BinaryForSourceQueryTest.java |  2 +-
 .../netbeans/api/java/queries/SourceForBinaryQueryTest.java | 10 +++++-----
 6 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/ide/api.java.classpath/src/org/netbeans/api/java/classpath/ClassLoaderSupport.java b/ide/api.java.classpath/src/org/netbeans/api/java/classpath/ClassLoaderSupport.java
index 4067d7b..725a058 100644
--- a/ide/api.java.classpath/src/org/netbeans/api/java/classpath/ClassLoaderSupport.java
+++ b/ide/api.java.classpath/src/org/netbeans/api/java/classpath/ClassLoaderSupport.java
@@ -27,6 +27,7 @@ import java.security.CodeSource;
 import java.security.PermissionCollection;
 import java.security.Permissions;
 import java.util.ArrayDeque;
+import java.util.ArrayList;
 import java.util.Deque;
 import java.util.HashMap;
 import java.util.List;
@@ -90,8 +91,8 @@ final class ClassLoaderSupport extends URLClassLoader implements FileChangeListe
      * @throws ClassNotFoundException
      */
     @Override
-    protected Class findClass (String name) throws ClassNotFoundException {
-        Class c = super.findClass (name);
+    protected Class<?> findClass (String name) throws ClassNotFoundException {
+        Class<?> c = super.findClass (name);
         if (c != null) {
             org.openide.filesystems.FileObject fo;
             String resName = name.replace('.', '/') + ".class"; // NOI18N
@@ -256,18 +257,18 @@ final class ClassLoaderSupport extends URLClassLoader implements FileChangeListe
     }
 
     private void removeAllListeners() {
-        Map.Entry[] removeListenerFrom;
+        List<Map.Entry<FileObject, Boolean>> removeListenerFrom;
         synchronized(lock){
             detachedFromCp = true;  //No need to add more listeners
             if (emittedFileObjects.isEmpty()) {
                 return;
             }
-            removeListenerFrom = emittedFileObjects.entrySet().toArray(new Map.Entry[emittedFileObjects.size()]);
+            removeListenerFrom = new ArrayList<>(emittedFileObjects.entrySet());
             emittedFileObjects.clear();
         }
-        for (Map.Entry e : removeListenerFrom) {
+        for (Map.Entry<FileObject, Boolean> e : removeListenerFrom) {
             if (e.getValue() == Boolean.TRUE) {
-                ((FileObject)e.getKey()).removeFileChangeListener(listener);
+                e.getKey().removeFileChangeListener(listener);
             }
         }
     }
diff --git a/ide/api.java.classpath/src/org/netbeans/api/java/queries/BinaryForSourceQuery.java b/ide/api.java.classpath/src/org/netbeans/api/java/queries/BinaryForSourceQuery.java
index 99a3f19..254b505 100644
--- a/ide/api.java.classpath/src/org/netbeans/api/java/queries/BinaryForSourceQuery.java
+++ b/ide/api.java.classpath/src/org/netbeans/api/java/queries/BinaryForSourceQuery.java
@@ -232,11 +232,11 @@ public final class BinaryForSourceQuery {
     static final class QueriesAccessorImpl extends QueriesAccessor {
         QueriesAccessorImpl() {
         }
-        private final Map<Object, Result2Impl> cache = new WeakHashMap<>();
+        private final Map<Object, Result2Impl<?>> cache = new WeakHashMap<>();
 
         @Override
         public synchronized <T> Result2 create(BinaryForSourceQueryImplementation2<T> impl, T value) {
-            Result2Impl result = cache.get(value);
+            Result2Impl<?> result = cache.get(value);
             if (result == null) {
                 result = new Result2Impl<>(impl, value);
                 cache.put(value, result);
diff --git a/ide/api.java.classpath/src/org/netbeans/modules/java/classpath/ClassPathAccessor.java b/ide/api.java.classpath/src/org/netbeans/modules/java/classpath/ClassPathAccessor.java
index 5a1d422..605818b 100644
--- a/ide/api.java.classpath/src/org/netbeans/modules/java/classpath/ClassPathAccessor.java
+++ b/ide/api.java.classpath/src/org/netbeans/modules/java/classpath/ClassPathAccessor.java
@@ -33,7 +33,7 @@ public abstract class ClassPathAccessor {
     public static synchronized ClassPathAccessor getDefault() {
         ClassPathAccessor instance = DEFAULT;
         if (instance == null) {
-            Class c = ClassPath.class;
+            Class<?> c = ClassPath.class;
             try {
                 Class.forName(c.getName(), true, c.getClassLoader());
                 instance = DEFAULT;
diff --git a/ide/api.java.classpath/test/unit/src/org/netbeans/api/java/classpath/ClassPathTest.java b/ide/api.java.classpath/test/unit/src/org/netbeans/api/java/classpath/ClassPathTest.java
index 1eaf4f1..667229d 100644
--- a/ide/api.java.classpath/test/unit/src/org/netbeans/api/java/classpath/ClassPathTest.java
+++ b/ide/api.java.classpath/test/unit/src/org/netbeans/api/java/classpath/ClassPathTest.java
@@ -158,7 +158,7 @@ public class ClassPathTest extends NbTestCase {
         assertTrue (cp.findResource("org/me/None.txt")==null);
         
         //findAllResources
-        List res = cp.findAllResources ("org/me/Foo.txt");
+        List<FileObject> res = cp.findAllResources ("org/me/Foo.txt");
         assertTrue (res.size() == 2);
         assertTrue (res.contains(testFo_1));
         assertTrue (res.contains(testFo_2));
@@ -339,8 +339,8 @@ public class ClassPathTest extends NbTestCase {
         }
 
         public synchronized void removeResource (URL resource) {
-            for (Iterator it = this.resources.iterator(); it.hasNext();) {
-                PathResourceImplementation pr = (PathResourceImplementation) it.next ();
+            for (Iterator<PathResourceImplementation> it = this.resources.iterator(); it.hasNext();) {
+                PathResourceImplementation pr = it.next ();
                 if (Arrays.asList(pr.getRoots()).contains (resource)) {
                     this.resources.remove (pr);
                     this.support.firePropertyChange (ClassPathImplementation.PROP_RESOURCES,null,null);
diff --git a/ide/api.java.classpath/test/unit/src/org/netbeans/api/java/queries/BinaryForSourceQueryTest.java b/ide/api.java.classpath/test/unit/src/org/netbeans/api/java/queries/BinaryForSourceQueryTest.java
index dd036da..d64d5b2 100644
--- a/ide/api.java.classpath/test/unit/src/org/netbeans/api/java/queries/BinaryForSourceQueryTest.java
+++ b/ide/api.java.classpath/test/unit/src/org/netbeans/api/java/queries/BinaryForSourceQueryTest.java
@@ -52,7 +52,7 @@ public class BinaryForSourceQueryTest extends NbTestCase {
     
     @Override
     protected void setUp () throws IOException {
-        MockServices.setServices(new Class[] {CPProvider.class, SFBQImpl.class});
+        MockServices.setServices(new Class<?>[] {CPProvider.class, SFBQImpl.class});
         this.clearWorkDir();
         File wd = this.getWorkDir();
         FileObject root = FileUtil.toFileObject(wd);
diff --git a/ide/api.java.classpath/test/unit/src/org/netbeans/api/java/queries/SourceForBinaryQueryTest.java b/ide/api.java.classpath/test/unit/src/org/netbeans/api/java/queries/SourceForBinaryQueryTest.java
index 1b358b1..05edd10 100644
--- a/ide/api.java.classpath/test/unit/src/org/netbeans/api/java/queries/SourceForBinaryQueryTest.java
+++ b/ide/api.java.classpath/test/unit/src/org/netbeans/api/java/queries/SourceForBinaryQueryTest.java
@@ -177,7 +177,7 @@ public class SourceForBinaryQueryTest extends NbTestCase {
                 fired.set(true);
             }
         });
-        ((LeafSFBQImpl)DelegatingSFBImpl.impl).lastResult.fire();
+        LeafSFBQImpl.lastResult.fire();
         res.removeChangeListener(l);
         assertTrue(fired.get());
     }
@@ -217,14 +217,14 @@ public class SourceForBinaryQueryTest extends NbTestCase {
         
         
         public Result findSourceRoots2(URL binaryRoot) {
-            if (this.impl == null) {
+            if (DelegatingSFBImpl.impl == null) {
                 throw new IllegalStateException ();
             }
-            else if (this.impl instanceof SourceForBinaryQueryImplementation2) {
-                return ((SourceForBinaryQueryImplementation2)this.impl).findSourceRoots2(binaryRoot);
+            else if (DelegatingSFBImpl.impl instanceof SourceForBinaryQueryImplementation2) {
+                return ((SourceForBinaryQueryImplementation2)DelegatingSFBImpl.impl).findSourceRoots2(binaryRoot);
             }
             else {
-                final SourceForBinaryQuery.Result result = this.impl.findSourceRoots(binaryRoot);
+                final SourceForBinaryQuery.Result result = DelegatingSFBImpl.impl.findSourceRoots(binaryRoot);
                 return result == null ? null : asResult(result);
             }
         }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists