This is an automated email from the ASF dual-hosted git repository. stbischof pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/felix-dev.git
commit a8ac32bad1d00bdaea06ef12a29760217ad1e00a Author: Stefan Bischof <stbisc...@bipolis.org> AuthorDate: Sat Apr 5 10:38:53 2025 +0200 [fw] use valueOf, or auto boxing Signed-off-by: Stefan Bischof <stbisc...@bipolis.org> --- .../src/main/java/org/apache/felix/framework/Felix.java | 14 +++++++------- .../apache/felix/framework/ServiceRegistrationImpl.java | 8 ++++---- .../org/apache/felix/framework/cache/BundleArchive.java | 6 +++--- .../org/apache/felix/framework/cache/DirectoryContent.java | 2 +- .../java/org/apache/felix/framework/cache/JarContent.java | 2 +- .../felix/framework/capabilityset/CapabilitySet.java | 2 +- .../apache/felix/framework/capabilityset/SimpleFilter.java | 8 ++++---- .../java/org/apache/felix/framework/util/SecureAction.java | 2 +- .../framework/util/manifestparser/ManifestParser.java | 8 ++++---- .../org/apache/felix/framework/cache/BundleCacheTest.java | 6 +++--- 10 files changed, 29 insertions(+), 29 deletions(-) diff --git a/framework/src/main/java/org/apache/felix/framework/Felix.java b/framework/src/main/java/org/apache/felix/framework/Felix.java index 5c110df88d..fc3ec4a5ab 100644 --- a/framework/src/main/java/org/apache/felix/framework/Felix.java +++ b/framework/src/main/java/org/apache/felix/framework/Felix.java @@ -748,7 +748,7 @@ public class Felix extends BundleImpl implements Framework // Add the system bundle to the set of installed bundles. maps[LOCATION_MAP_IDX].put(_getLocation(), this); - maps[IDENTIFIER_MAP_IDX].put(new Long(0), this); + maps[IDENTIFIER_MAP_IDX].put(0L, this); m_installedBundles = maps; @@ -934,7 +934,7 @@ public class Felix extends BundleImpl implements Framework new TreeMap<Long, BundleImpl>(m_installedBundles[IDENTIFIER_MAP_IDX]) }; maps[LOCATION_MAP_IDX].remove(((BundleImpl) bundle)._getLocation()); - maps[IDENTIFIER_MAP_IDX].remove(new Long(((BundleImpl) bundle).getBundleId())); + maps[IDENTIFIER_MAP_IDX].remove(Long.valueOf(((BundleImpl) bundle).getBundleId())); m_installedBundles = maps; m_logger.log( @@ -2962,7 +2962,7 @@ public class Felix extends BundleImpl implements Framework target = (BundleImpl) maps[LOCATION_MAP_IDX].remove(bundle._getLocation()); if (target != null) { - maps[IDENTIFIER_MAP_IDX].remove(new Long(target.getBundleId())); + maps[IDENTIFIER_MAP_IDX].remove(Long.valueOf(target.getBundleId())); m_installedBundles = maps; // Set the bundle's persistent state to uninstalled. @@ -3192,7 +3192,7 @@ public class Felix extends BundleImpl implements Framework new TreeMap<Long, BundleImpl>(m_installedBundles[IDENTIFIER_MAP_IDX]) }; maps[LOCATION_MAP_IDX].put(bundle._getLocation(), bundle); - maps[IDENTIFIER_MAP_IDX].put(new Long(bundle.getBundleId()), bundle); + maps[IDENTIFIER_MAP_IDX].put(Long.valueOf(bundle.getBundleId()), bundle); m_installedBundles = maps; } finally @@ -3357,7 +3357,7 @@ public class Felix extends BundleImpl implements Framework new TreeMap<Long, BundleImpl>(m_installedBundles[IDENTIFIER_MAP_IDX]) }; maps[LOCATION_MAP_IDX].put(location, bundle); - maps[IDENTIFIER_MAP_IDX].put(new Long(bundle.getBundleId()), bundle); + maps[IDENTIFIER_MAP_IDX].put(Long.valueOf(bundle.getBundleId()), bundle); m_installedBundles = maps; } finally @@ -3469,7 +3469,7 @@ public class Felix extends BundleImpl implements Framework Bundle getBundle(BundleContext bc, long id) { BundleImpl bundle = (BundleImpl) - m_installedBundles[IDENTIFIER_MAP_IDX].get(new Long(id)); + m_installedBundles[IDENTIFIER_MAP_IDX].get(Long.valueOf(id)); if (bundle != null) { List<BundleImpl> uninstalledBundles = m_uninstalledBundles; @@ -3531,7 +3531,7 @@ public class Felix extends BundleImpl implements Framework Bundle getBundle(long id) { BundleImpl bundle = (BundleImpl) - m_installedBundles[IDENTIFIER_MAP_IDX].get(new Long(id)); + m_installedBundles[IDENTIFIER_MAP_IDX].get(Long.valueOf(id)); if (bundle != null) { return bundle; diff --git a/framework/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java b/framework/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java index ed4b8e5b9b..0c13371079 100644 --- a/framework/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java +++ b/framework/src/main/java/org/apache/felix/framework/ServiceRegistrationImpl.java @@ -685,14 +685,14 @@ class ServiceRegistrationImpl implements ServiceRegistration Object otherRankObj = other.getProperty(Constants.SERVICE_RANKING); // If no rank, then spec says it defaults to zero. - rankObj = (rankObj == null) ? new Integer(0) : rankObj; - otherRankObj = (otherRankObj == null) ? new Integer(0) : otherRankObj; + rankObj = (rankObj == null) ? Integer.valueOf(0) : rankObj; + otherRankObj = (otherRankObj == null) ? Integer.valueOf(0) : otherRankObj; // If rank is not Integer, then spec says it defaults to zero. Integer rank = (rankObj instanceof Integer) - ? (Integer) rankObj : new Integer(0); + ? (Integer) rankObj : 0; Integer otherRank = (otherRankObj instanceof Integer) - ? (Integer) otherRankObj : new Integer(0); + ? (Integer) otherRankObj : 0; // Sort by rank in ascending order. if (rank.compareTo(otherRank) < 0) diff --git a/framework/src/main/java/org/apache/felix/framework/cache/BundleArchive.java b/framework/src/main/java/org/apache/felix/framework/cache/BundleArchive.java index 3125ba4f35..9e958d8b95 100644 --- a/framework/src/main/java/org/apache/felix/framework/cache/BundleArchive.java +++ b/framework/src/main/java/org/apache/felix/framework/cache/BundleArchive.java @@ -152,7 +152,7 @@ public class BundleArchive initialize(); // Add a revision for the content. - reviseInternal(false, new Long(0), m_originalLocation, is); + reviseInternal(false, 0L, m_originalLocation, is); } /** @@ -457,8 +457,8 @@ public class BundleArchive throws Exception { Long revNum = (m_revisions.isEmpty()) - ? new Long(0) - : new Long(m_revisions.lastKey().longValue() + 1); + ? 0L + : m_revisions.lastKey().longValue() + 1; reviseInternal(false, revNum, location, is); } diff --git a/framework/src/main/java/org/apache/felix/framework/cache/DirectoryContent.java b/framework/src/main/java/org/apache/felix/framework/cache/DirectoryContent.java index b5187d131d..e76ed4f991 100644 --- a/framework/src/main/java/org/apache/felix/framework/cache/DirectoryContent.java +++ b/framework/src/main/java/org/apache/felix/framework/cache/DirectoryContent.java @@ -346,7 +346,7 @@ public class DirectoryContent implements Content } Integer libCount = (Integer) m_nativeLibMap.get(entryName); // Either set or increment the library count. - libCount = (libCount == null) ? new Integer(0) : new Integer(libCount.intValue() + 1); + libCount = (libCount == null) ? 0 : libCount.intValue() + 1; m_nativeLibMap.put(entryName, libCount); File libFile = new File( libDir, libCount.toString() + File.separatorChar + entryName); diff --git a/framework/src/main/java/org/apache/felix/framework/cache/JarContent.java b/framework/src/main/java/org/apache/felix/framework/cache/JarContent.java index 19b76819e2..f9e4dbacb6 100644 --- a/framework/src/main/java/org/apache/felix/framework/cache/JarContent.java +++ b/framework/src/main/java/org/apache/felix/framework/cache/JarContent.java @@ -353,7 +353,7 @@ public class JarContent implements Content } Integer libCount = (Integer) m_nativeLibMap.get(entryName); // Either set or increment the library count. - libCount = (libCount == null) ? new Integer(0) : new Integer(libCount.intValue() + 1); + libCount = (libCount == null) ? 0 : libCount.intValue() + 1; m_nativeLibMap.put(entryName, libCount); File libFile = new File( libDir, libCount.toString() + File.separatorChar + entryName); diff --git a/framework/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java b/framework/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java index 5790e08513..01f4d59126 100644 --- a/framework/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java +++ b/framework/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java @@ -585,7 +585,7 @@ public class CapabilitySet // does not take a string, so handle it separately. if (lhs instanceof Character) { - rhs = new Character(rhsString.charAt(0)); + rhs = Character.valueOf(rhsString.charAt(0)); } else if(lhs instanceof Version && rhsString.indexOf(',') >= 0) { diff --git a/framework/src/main/java/org/apache/felix/framework/capabilityset/SimpleFilter.java b/framework/src/main/java/org/apache/felix/framework/capabilityset/SimpleFilter.java index 5c77d52fe8..f5a9fb5c50 100644 --- a/framework/src/main/java/org/apache/felix/framework/capabilityset/SimpleFilter.java +++ b/framework/src/main/java/org/apache/felix/framework/capabilityset/SimpleFilter.java @@ -215,7 +215,7 @@ public class SimpleFilter } else { - stack.add(0, new Integer(idx)); + stack.add(0, Integer.valueOf(idx)); } } else if (filter.charAt(idx) == '|') @@ -228,7 +228,7 @@ public class SimpleFilter } else { - stack.add(0, new Integer(idx)); + stack.add(0, Integer.valueOf(idx)); } } else if (filter.charAt(idx) == '!') @@ -241,12 +241,12 @@ public class SimpleFilter } else { - stack.add(0, new Integer(idx)); + stack.add(0, Integer.valueOf(idx)); } } else { - stack.add(0, new Integer(idx)); + stack.add(0, Integer.valueOf(idx)); } } else if (!isEscaped && (filter.charAt(idx) == ')')) diff --git a/framework/src/main/java/org/apache/felix/framework/util/SecureAction.java b/framework/src/main/java/org/apache/felix/framework/util/SecureAction.java index 8d6ca4489a..c121a4f581 100644 --- a/framework/src/main/java/org/apache/felix/framework/util/SecureAction.java +++ b/framework/src/main/java/org/apache/felix/framework/util/SecureAction.java @@ -267,7 +267,7 @@ public class SecureAction { Actions actions = (Actions) m_actions.get(); actions.set(Actions.CREATE_URL_ACTION, protocol, host, - new Integer(port), path, handler); + Integer.valueOf(port), path, handler); return (URL) AccessController.doPrivileged(actions, m_acc); } catch (PrivilegedActionException ex) diff --git a/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java b/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java index 43c7eb41a8..371f089ad0 100644 --- a/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java +++ b/framework/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java @@ -748,7 +748,7 @@ public class ManifestParser { clause.m_attrs.put( entry.getKey(), - new Double(clause.m_attrs.get(entry.getKey()).toString().trim())); + Double.valueOf(clause.m_attrs.get(entry.getKey()).toString().trim())); } else if (type.equals("Version")) { @@ -760,7 +760,7 @@ public class ManifestParser { clause.m_attrs.put( entry.getKey(), - new Long(clause.m_attrs.get(entry.getKey()).toString().trim())); + Long.valueOf(clause.m_attrs.get(entry.getKey()).toString().trim())); } else if (type.startsWith("List")) { @@ -793,7 +793,7 @@ public class ManifestParser } else if (listType.equals("Double")) { - values.add(new Double(token.trim())); + values.add(Double.valueOf(token.trim())); } else if (listType.equals("Version")) { @@ -801,7 +801,7 @@ public class ManifestParser } else if (listType.equals("Long")) { - values.add(new Long(token.trim())); + values.add(Long.valueOf(token.trim())); } else { diff --git a/framework/src/test/java/org/apache/felix/framework/cache/BundleCacheTest.java b/framework/src/test/java/org/apache/felix/framework/cache/BundleCacheTest.java index 8160daa5e9..155455731f 100644 --- a/framework/src/test/java/org/apache/felix/framework/cache/BundleCacheTest.java +++ b/framework/src/test/java/org/apache/felix/framework/cache/BundleCacheTest.java @@ -193,7 +193,7 @@ class BundleCacheTest assertThat(archive).isNotNull(); - assertThat(archive.getCurrentRevisionNumber()).isEqualTo(Long.valueOf(0)); + assertThat(archive.getCurrentRevisionNumber()).isEqualTo(0L); revision(archive); @@ -204,7 +204,7 @@ class BundleCacheTest archive.revise(location, file != null ? new FileInputStream(file) : null); - assertThat(archive.getCurrentRevisionNumber()).isEqualTo(Long.valueOf(1)); + assertThat(archive.getCurrentRevisionNumber()).isEqualTo(1L); revision(archive); @@ -216,7 +216,7 @@ class BundleCacheTest archive.purge(); - assertThat(archive.getCurrentRevisionNumber()).isEqualTo(Long.valueOf(1)); + assertThat(archive.getCurrentRevisionNumber()).isEqualTo(1L); revision(archive);